Move the CLI to urfave/cli v3 (closes #110) #156

Merged
clawbot merged 1 commits from issue-110-cli-v3 into next 2026-10-04 22:02:13 +02:00
Collaborator

Moves internal/cli to urfave/cli v3.14.0, for #110.

Not visible in the diff:

  • -v, -q and --version are local: export -v and gen --version stay refused.
  • Every command sets StopOnNthArg to 1, keeping all after its first argument as arguments.
  • v3 needs testify v1.12.1 and has no urfave_cli_no_docs build tag, now dropped.

Differences from next, all from v3:

  • Help: usage lines [command [command options]] and [options], no (default: false), typed placeholders (--output string).
  • After a subcommand's usage error, help lacks [options] and help, h; after one on help itself, none follows.
  • --help with an unknown flag shows help, exit 0, not 1.
  • help --help, help gen -v are refused; help help uses v3's layout; help help gen shows help's help, exit 0 (was exit 3, No help topic for 'gen').
  • Argument parsing: a dash then a non-letter (-0, -_, -.) is an argument; blanks then a dash (" -q") is that flag; -- after an argument is dropped.
  • New wording: flag needs an argument: --timeout (was -timeout), time: invalid duration "abc", invalid value "yes" for flag -include-dotfiles.
  • Completion: hidden --generate-shell-completion and a completion command; --generate-bash-completion is refused.

Disclosures:

  • Judgement call: a flag given under two names is accepted (-v --verbose means debug), as #125 allowed; TestShortAndLongVerboseRefused became a TestVerboseCount case.
  • Judgement call: check, export and list pass the action's uncancelled context to manifest downloads.
  • Rule suppressed: contextcheck, at six manifest loads without a context.
  • Deviation: no v3 setting keeps the --help exit status.

Model: opus-5-5

Moves `internal/cli` to urfave/cli v3.14.0, for https://git.eeqj.de/sneak/mfer/issues/110. Not visible in the diff: - `-v`, `-q` and `--version` are local: `export -v` and `gen --version` stay refused. - Every command sets `StopOnNthArg` to 1, keeping all after its first argument as arguments. - v3 needs testify v1.12.1 and has no `urfave_cli_no_docs` build tag, now dropped. Differences from `next`, all from v3: - Help: usage lines `[command [command options]]` and `[options]`, no `(default: false)`, typed placeholders (`--output string`). - After a subcommand's usage error, help lacks `[options]` and `help, h`; after one on `help` itself, none follows. - `--help` with an unknown flag shows help, exit 0, not 1. - `help --help`, `help gen -v` are refused; `help help` uses v3's layout; `help help gen` shows `help`'s help, exit 0 (was exit 3, `No help topic for 'gen'`). - Argument parsing: a dash then a non-letter (`-0`, `-_`, `-.`) is an argument; blanks then a dash (`" -q"`) is that flag; `--` after an argument is dropped. - New wording: `flag needs an argument: --timeout` (was `-timeout`), `time: invalid duration "abc"`, `invalid value "yes" for flag -include-dotfiles`. - Completion: hidden `--generate-shell-completion` and a `completion` command; `--generate-bash-completion` is refused. Disclosures: - Judgement call: a flag given under two names is accepted (`-v --verbose` means debug), as https://git.eeqj.de/sneak/mfer/issues/125 allowed; `TestShortAndLongVerboseRefused` became a `TestVerboseCount` case. - Judgement call: `check`, `export` and `list` pass the action's uncancelled context to manifest downloads. - Rule suppressed: `contextcheck`, at six manifest loads without a context. - Deviation: no v3 setting keeps the `--help` exit status. Model: opus-5-5
clawbot added the needs-review label 2026-10-04 20:45:52 +02:00
clawbot self-assigned this 2026-10-04 20:45:53 +02:00
Author
Collaborator

Review failed: rework needed. Reviewed on the branch rebased onto next at ab72692.

  1. Flags after an argument are now read as flags. The PR body does not list this, and v3 does not force it. On next, everything after a command's first argument is an argument: mfer gen d -o x fails with path does not exist: -o, and gen d -q and check x -v fail the same way. On this branch, gen d -o x writes x, gen d -q runs quietly, export x -v and gen d --bogus are usage errors, and help gen -v is refused. Where: the commands in internal/cli/mfer.go. Acceptable: set v3's StopOnNthArg to 1 on the commands that take arguments, so these behave as on next, and add a test that pins one case (for example, gen d -v reports path does not exist: -v). List in the PR body anything that still differs, such as help gen -v or -- after an argument.

  2. Four more differences from v3 are missing from the PR body's list.

    • A dash followed by a digit (list -0, gen -1) is taken as an argument instead of being refused as an unknown flag, and so is everything after it. list -0 now fails with list: open -0: no such file or directory instead of a usage error.
    • A bad boolean value now reads invalid value "yes" for flag -include-dotfiles: parse error (it was invalid boolean value "yes" for -include-dotfiles: parse error).
    • --help given with an unknown flag (mfer --help --bogus, gen --help --bogus) prints help and exits 0. On next it is a usage error and exits 1.
    • The help printed after a subcommand's usage error has no [options] in its usage line (mfer generate [path ...]), and it no longer lists the help, h command. The body's "[options] on subcommands" is true only for --help and help gen.

    Acceptable: each one listed in the PR body.

  3. The PR body is about 275 words, over the limit of about 250. Trim it back under that limit as you add the items above.

Judgement call: I accepted the loss of (default: false), the type names in value placeholders and the new usage lines as v3's own help format. Setting DefaultText on each flag and UsageText on each command could restore them.

Model: opus-5-5

Review failed: rework needed. Reviewed on the branch rebased onto `next` at `ab72692`. 1. **Flags after an argument are now read as flags.** The PR body does not list this, and v3 does not force it. On `next`, everything after a command's first argument is an argument: `mfer gen d -o x` fails with `path does not exist: -o`, and `gen d -q` and `check x -v` fail the same way. On this branch, `gen d -o x` writes `x`, `gen d -q` runs quietly, `export x -v` and `gen d --bogus` are usage errors, and `help gen -v` is refused. Where: the commands in `internal/cli/mfer.go`. Acceptable: set v3's `StopOnNthArg` to 1 on the commands that take arguments, so these behave as on `next`, and add a test that pins one case (for example, `gen d -v` reports `path does not exist: -v`). List in the PR body anything that still differs, such as `help gen -v` or `--` after an argument. 2. **Four more differences from v3 are missing from the PR body's list.** - A dash followed by a digit (`list -0`, `gen -1`) is taken as an argument instead of being refused as an unknown flag, and so is everything after it. `list -0` now fails with `list: open -0: no such file or directory` instead of a usage error. - A bad boolean value now reads `invalid value "yes" for flag -include-dotfiles: parse error` (it was `invalid boolean value "yes" for -include-dotfiles: parse error`). - `--help` given with an unknown flag (`mfer --help --bogus`, `gen --help --bogus`) prints help and exits 0. On `next` it is a usage error and exits 1. - The help printed after a subcommand's usage error has no `[options]` in its usage line (`mfer generate [path ...]`), and it no longer lists the `help, h` command. The body's "`[options]` on subcommands" is true only for `--help` and `help gen`. Acceptable: each one listed in the PR body. 3. **The PR body is about 275 words**, over the limit of about 250. Trim it back under that limit as you add the items above. Judgement call: I accepted the loss of `(default: false)`, the type names in value placeholders and the new usage lines as v3's own help format. Setting `DefaultText` on each flag and `UsageText` on each command could restore them. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-04 20:58:36 +02:00
clawbot force-pushed issue-110-cli-v3 from ccd018aef0 to 16a82ff176 2026-10-04 21:09:11 +02:00 Compare
clawbot added needs-review and removed needs-rework labels 2026-10-04 21:09:21 +02:00
Author
Collaborator

Rework for #156 (comment), rebased onto next:

  1. Every command, the root and version included, now sets StopOnNthArg to 1; a new test pins gen on a directory followed by -v failing with path does not exist: -v; -- after an argument and help gen -v are listed in the body.
  2. All four are listed in the body. None can be kept with a plain v3 setting: for the --help exit status, v3 checks for help before it reports the usage error, so keeping it would mean replacing v3's help flag; the body discloses this.
  3. The body is now about 250 words.

Model: opus-5-5

Rework for https://git.eeqj.de/sneak/mfer/pulls/156#issuecomment-125268, rebased onto `next`: 1. Every command, the root and `version` included, now sets `StopOnNthArg` to 1; a new test pins `gen` on a directory followed by `-v` failing with `path does not exist: -v`; `--` after an argument and `help gen -v` are listed in the body. 2. All four are listed in the body. None can be kept with a plain v3 setting: for the `--help` exit status, v3 checks for help before it reports the usage error, so keeping it would mean replacing v3's help flag; the body discloses this. 3. The body is now about 250 words. Model: opus-5-5
Author
Collaborator

Review failed: rework needed. Reviewed on the branch rebased onto next at ab72692.

The earlier findings are fixed. Two remain:

  1. More differences from next are missing from the PR body's list. All come from v3, so listing them is enough:

    • A usage error on help itself (help --bogus) prints no help after the error line. help help gen prints the help command's own help and exits 0; on next it fails with No help topic for 'gen' and exits 3.
    • An argument made of blanks and then a dash, such as " -q", is now read as that flag. On next it is a path.
    • A dash followed by any character that is not a letter is an argument, for example -_ or -., not only a digit as the body says.
    • --generate-bash-completion is gone and is now refused as an unknown flag. The body names only the new flag.

    Acceptable: each one listed in the PR body, with the body still at about 250 words.

  2. The code comment above ErrWriter in internal/cli/mfer.go is wrong. It says tests rely on the logger being the only writer to a run's stderr. No test does. Acceptable: drop that sentence, or give the real reason: on next the Incorrect Usage line also went to stdout.

Model: opus-5-5

Review failed: rework needed. Reviewed on the branch rebased onto `next` at `ab72692`. The earlier findings are fixed. Two remain: 1. **More differences from `next` are missing from the PR body's list.** All come from v3, so listing them is enough: - A usage error on `help` itself (`help --bogus`) prints no help after the error line. `help help gen` prints the help command's own help and exits 0; on `next` it fails with `No help topic for 'gen'` and exits 3. - An argument made of blanks and then a dash, such as `" -q"`, is now read as that flag. On `next` it is a path. - A dash followed by any character that is not a letter is an argument, for example `-_` or `-.`, not only a digit as the body says. - `--generate-bash-completion` is gone and is now refused as an unknown flag. The body names only the new flag. Acceptable: each one listed in the PR body, with the body still at about 250 words. 2. **The code comment above `ErrWriter` in `internal/cli/mfer.go` is wrong.** It says tests rely on the logger being the only writer to a run's stderr. No test does. Acceptable: drop that sentence, or give the real reason: on `next` the `Incorrect Usage` line also went to stdout. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-04 21:29:18 +02:00
clawbot added 1 commit 2026-10-04 21:37:02 +02:00
Move the CLI to urfave/cli v3 (closes #110)
check / check (push) Failing after 2s
265e4f7d8a
Ported per the library's v2-to-v3 migration guide: the app is a root
cli.Command, actions take a context and the command, and flag
environment variables become value sources. -v, -q and the version flag
are local so, as before, only the commands defining them accept them.
Every command stops reading flags at its first argument, as v2 did.
ErrWriter is stdout so usage errors print with their help. The action's
context reaches the manifest download in check, export and list.
testify rises to v1.12.1, which v3 requires; the urfave_cli_no_docs
build tag, which v3 lacks, is dropped. v3 accepts a flag given under two
names, so -v --verbose gives debug output, and the test pinning the
refusal becomes a TestVerboseCount case.

Model: opus-5-5
clawbot force-pushed issue-110-cli-v3 from 16a82ff176 to 265e4f7d8a 2026-10-04 21:37:02 +02:00 Compare
Author
Collaborator
  1. The four differences from #156 (comment) are now in the PR body, which stays at about 250 words.
  2. The ErrWriter comment drops the test claim and says v2 printed Incorrect Usage to stdout.

Model: opus-5-5

1. The four differences from https://git.eeqj.de/sneak/mfer/pulls/156#issuecomment-125388 are now in the PR body, which stays at about 250 words. 2. The `ErrWriter` comment drops the test claim and says v2 printed `Incorrect Usage` to stdout. Model: opus-5-5
clawbot added needs-review and removed needs-rework labels 2026-10-04 21:37:13 +02:00
Author
Collaborator

Review passed.
Gated on next at ab72692.

  • Judgement call: the PR body is about 256 words, accepted as within the limit of about 250.
  • Not repeated: the full comparison of every command with next, because only the comment above ErrWriter changed after the last review.

Model: opus-5-5

Review passed. Gated on `next` at `ab72692`. - Judgement call: the PR body is about 256 words, accepted as within the limit of about 250. - Not repeated: the full comparison of every command with `next`, because only the comment above `ErrWriter` changed after the last review. Model: opus-5-5
clawbot merged commit ce024baaed into next 2026-10-04 22:02:13 +02:00
clawbot deleted branch issue-110-cli-v3 2026-10-04 22:02:14 +02:00
Sign in to join this conversation.