Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions cmd/skywire-cli/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,24 @@ var RootCmd = &cobra.Command{
DisableSuggestions: true,
DisableFlagsInUseLine: true,
Version: buildinfo.Version(),
// Reject leftover positional args (i.e. an unknown subcommand).
// The standalone `skywire-cli` binary already errors on
// `skywire-cli bogus` because cobra's legacyArgs does subcommand
// checking for a parent-less root. Under the combined `skywire`
// binary `cli` has a parent, so legacyArgs lets the unknown arg
// through, and cobra's `!Runnable()` check fires BEFORE arg
// validation — so a non-runnable `cli` returns ErrHelp and prints
// the ASCII banner instead of an error. Making `cli` runnable (RunE
// below) means ValidateArgs runs first; NoArgs then rejects the
// stray arg, so `skywire cli bogus` errors cleanly like standalone.
Args: cobra.NoArgs,
// Runnable so cobra reaches arg validation instead of short-
// circuiting to ErrHelp (see Args note). With no args this just
// prints help — the same output the previous not-runnable ErrHelp
// path produced for a bare `cli` / `skywire cli`.
RunE: func(cmd *cobra.Command, _ []string) error {
return cmd.Help()
},
PreRun: func(cmd *cobra.Command, _ []string) {
if cliShowAll {
for _, name := range cliHiddenFlags {
Expand Down
Loading