fix(skywire-cli): error on unknown subcommand under combined 'skywire cli' - #4074
Open
0pcom wants to merge 1 commit into
Open
fix(skywire-cli): error on unknown subcommand under combined 'skywire cli'#40740pcom wants to merge 1 commit into
0pcom wants to merge 1 commit into
Conversation
0pcom
force-pushed
the
fix/cli-unknown-subcommand-error
branch
from
August 22, 2026 14:16
d6d203b to
dfebc4c
Compare
… cli' Bare `skywire cli <unknown>` printed the ASCII banner instead of an error. Cause: under the combined `skywire` binary, `cli` is a non-root command, so cobra's legacyArgs skips subcommand checking (that only runs for a parent-less root), and cobra's `!Runnable()` check fires before arg validation — a non-runnable `cli` returns ErrHelp and prints the banner. The standalone `skywire-cli` errors correctly because it is the root. Make `cli` runnable via a RunE that prints help (matching the old bare-invocation output) and add Args: cobra.NoArgs so cobra reaches arg validation and rejects the stray arg. `skywire cli bogus` now errors cleanly; bare `skywire cli` still prints help; valid subcommands are unaffected.
0pcom
force-pushed
the
fix/cli-unknown-subcommand-error
branch
from
August 22, 2026 14:55
dfebc4c to
b258e38
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
skywire cli <unknown-subcommand>(e.g.skywire cli bogus) printed the ASCII banner instead of erroring. The standaloneskywire-cli boguserrors cleanly.Cause: under the combined
skywirebinary,cliis a non-root command. Cobra'slegacyArgsonly does unknown-subcommand checking for a parent-less root, so the stray arg passes; and cobra's!Runnable()check fires beforeValidateArgs, so a non-runnableclireturnsflag.ErrHelpand prints the banner. The standalone binary avoids this becausecli's RootCmd is the root there.Fix
In
cmd/skywire-cli/commands/root.go:Args: cobra.NoArgsso a leftover positional (unknown subcommand) is rejected;RunEthat prints help, makingclirunnable so cobra reaches arg validation instead of short-circuiting toErrHelp.Validation (combined + standalone binaries built locally)
skywire cli bogus→unknown command "bogus" for "skywire cli", exit 1 (was: banner).skywire cli(bare) → still prints help (same as before).skywire cli versionand other valid subcommands → unaffected.skywire-cli bogus(standalone) → still errors;skywire-clibare → still prints help.Backward-compatible: only the previously-misleading banner-on-typo path changes.