Read options after the path or URL and refuse a second argument (closes #196) #197

Merged
clawbot merged 1 commits from issue-196-options-after-argument into next 2026-10-13 14:21:57 +02:00
Collaborator

Fixes #196.

Every command read options only up to its first argument (StopOnNthArg set to 1, kept from urfave/cli v2 in the move to v3), and check, fetch, freshen, list and export ignored anything after that argument. So mfer check DIR --require-signature FPR passed an unsigned manifest, and mfer fetch URL --dest D wrote into the current directory.

internal/cli/mfer.go drops that setting from every command, so options are read wherever they appear and -- still ends them. The five one-argument commands get urfave/cli's ArgValidator hook, which refuses a second argument with unexpected argument "b" before the command does anything. gen takes several paths and changes only in where it reads options; version still ignores arguments.

The tests run each case from the issue through the CLI.

Worth knowing:

  • TestFlagAfterArgumentIsArgument asserted the defect (gen DIR -v read -v as a path). The gen -- -x test replaces it. No other existing test needed a change.
  • urfave/cli still stops reading options at an argument named help (its built-in subcommand) or at a - followed by a non-letter, such as -5. In the one-argument commands that leaves a second argument, which is refused; in gen the rest are read as paths.
  • A mistyped command followed by an option, mfer bogus -x, now reports the unknown option instead of the unknown command.

Model: opus-5-5

Fixes https://git.eeqj.de/sneak/mfer/issues/196. Every command read options only up to its first argument (`StopOnNthArg` set to 1, kept from urfave/cli v2 in the move to v3), and `check`, `fetch`, `freshen`, `list` and `export` ignored anything after that argument. So `mfer check DIR --require-signature FPR` passed an unsigned manifest, and `mfer fetch URL --dest D` wrote into the current directory. `internal/cli/mfer.go` drops that setting from every command, so options are read wherever they appear and `--` still ends them. The five one-argument commands get urfave/cli's `ArgValidator` hook, which refuses a second argument with `unexpected argument "b"` before the command does anything. `gen` takes several paths and changes only in where it reads options; `version` still ignores arguments. The tests run each case from the issue through the CLI. Worth knowing: - `TestFlagAfterArgumentIsArgument` asserted the defect (`gen DIR -v` read `-v` as a path). The `gen -- -x` test replaces it. No other existing test needed a change. - urfave/cli still stops reading options at an argument named `help` (its built-in subcommand) or at a `-` followed by a non-letter, such as `-5`. In the one-argument commands that leaves a second argument, which is refused; in `gen` the rest are read as paths. - A mistyped command followed by an option, `mfer bogus -x`, now reports the unknown option instead of the unknown command. Model: opus-5-5
clawbot added the needs-review label 2026-10-13 13:51:35 +02:00
clawbot self-assigned this 2026-10-13 13:51:35 +02:00
clawbot added 1 commit 2026-10-13 13:51:36 +02:00
Every command read options only up to its first argument, and check,
fetch, freshen, list and export dropped everything after it, so
`check DIR --require-signature FPR` passed an unsigned manifest. Options
are now read wherever they appear, as urfave/cli v3 does by default, and
`--` still ends them. Those five commands refuse a second argument,
naming it.

TestFlagAfterArgumentIsArgument asserted the defect (`gen DIR -v` read
`-v` as a path); a test that `gen -- -x` reads `-x` as a path replaces it.

Model: opus-5-5
Author
Collaborator

Review passed.

  • Judgement call: a first argument of help or h still runs the built-in help and exits 0 instead of the command, even after --, so mfer check h --require-signature FPR checks nothing; next behaves the same and #196 does not cover it, but the PR body's note on help describes only a help after the first argument.
  • Judgement call: mfer check DIR --help (and the same on every command) now fails with No help topic for 'DIR', as mfer check --help DIR already does on next; not counted against this change.

Model: opus-5-5

Review passed. - Judgement call: a first argument of `help` or `h` still runs the built-in help and exits 0 instead of the command, even after `--`, so `mfer check h --require-signature FPR` checks nothing; `next` behaves the same and https://git.eeqj.de/sneak/mfer/issues/196 does not cover it, but the PR body's note on `help` describes only a `help` after the first argument. - Judgement call: `mfer check DIR --help` (and the same on every command) now fails with `No help topic for 'DIR'`, as `mfer check --help DIR` already does on `next`; not counted against this change. Model: opus-5-5
clawbot merged commit 8f7170b77f into next 2026-10-13 14:21:57 +02:00
clawbot deleted branch issue-196-options-after-argument 2026-10-13 14:21:57 +02:00
Sign in to join this conversation.