Unknown subcommands of vault, unlocker, version and generate fail #186

Merged
clawbot merged 1 commits from fix/183-unknown-subcommand into next 2026-10-15 06:02:46 +02:00
Collaborator

Given a subcommand they do not have, secret vault, secret unlocker, secret version and secret generate printed their help and exited 0, so a script could not tell secret vault improt from a command that worked. Each now exits 1 with unknown command "improt" for "secret vault" followed by its usage, as any wrongly called command does. Given no arguments, each still prints its help and exits 0.

Issue: #183

Cobra looks at a command's Args only when the command has a RunE; without one it prints the help for any argument first. Each of the four parents therefore gets Args: cobra.NoArgs and a RunE that prints its help. Setting Args alone has no effect.

TestUnknownSubcommandFails runs the built binary for each parent, once with an unknown subcommand and once with nothing. TestNoVaultImportCommand (from #139) required the old answer to secret vault import, which the issue names as a command that must fail; it now requires the error.

  • Judgement call: the help of these four commands gains a usage line such as secret vault [flags], which cobra adds for any command that runs.
  • Judgement call: secret vault help used to print the help by accident and now fails like any other unknown subcommand; secret help vault and secret vault --help still work.
  • README.md describes neither behaviour, so it is unchanged.

Model: opus-5-5

Given a subcommand they do not have, `secret vault`, `secret unlocker`, `secret version` and `secret generate` printed their help and exited 0, so a script could not tell `secret vault improt` from a command that worked. Each now exits 1 with `unknown command "improt" for "secret vault"` followed by its usage, as any wrongly called command does. Given no arguments, each still prints its help and exits 0. Issue: https://git.eeqj.de/sneak/secret/issues/183 Cobra looks at a command's `Args` only when the command has a `RunE`; without one it prints the help for any argument first. Each of the four parents therefore gets `Args: cobra.NoArgs` and a `RunE` that prints its help. Setting `Args` alone has no effect. `TestUnknownSubcommandFails` runs the built binary for each parent, once with an unknown subcommand and once with nothing. `TestNoVaultImportCommand` (from https://git.eeqj.de/sneak/secret/issues/139) required the old answer to `secret vault import`, which the issue names as a command that must fail; it now requires the error. - Judgement call: the help of these four commands gains a usage line such as `secret vault [flags]`, which cobra adds for any command that runs. - Judgement call: `secret vault help` used to print the help by accident and now fails like any other unknown subcommand; `secret help vault` and `secret vault --help` still work. - `README.md` describes neither behaviour, so it is unchanged. Model: opus-5-5
clawbot added the needs-review label 2026-10-15 05:22:25 +02:00
clawbot self-assigned this 2026-10-15 05:22:25 +02:00
clawbot added 1 commit 2026-10-15 05:33:10 +02:00
Given a subcommand they do not have, `secret vault`, `secret unlocker`,
`secret version` and `secret generate` printed their help and exited 0,
so a mistyped command looked like a successful one. Each now exits 1
with `unknown command "<name>" for "secret <parent>"`, and with no
arguments still prints its help.

Cobra checks a command's Args only when it has a RunE, so each parent
gets `Args: cobra.NoArgs` and a RunE that prints its help. Args alone
changes nothing. TestNoVaultImportCommand required the old answer to
`secret vault import` and now requires the error.

Judgement call: their help now shows a `secret <parent> [flags]` usage
line, which cobra adds for any command that runs.
Judgement call: `secret vault help` now fails as an unknown subcommand;
`secret help vault` and `secret vault --help` still work.

Model: opus-5-5
clawbot force-pushed fix/183-unknown-subcommand from 7dfa13a76f to 596ebf0918 2026-10-15 05:33:10 +02:00 Compare
Author
Collaborator

Review passed.

Model: opus-5-5

Review passed. Model: opus-5-5
clawbot merged commit f0bf3b24a6 into next 2026-10-15 06:02:46 +02:00
clawbot deleted branch fix/183-unknown-subcommand 2026-10-15 06:02:47 +02:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/secret#186