Skip to content
Myr

Merge pull request #116 from sgotti/fix_flag_as_unknown_command_in_output

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Correctly print the unknown command name

authored by Eric Paris · committed by Eric Paris · parents a8f7f3d, fb86c5c · Browse files · 2 files+6 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+6 added−1 removed

  • other:+6 added−1 removed

2 files+6 added−1 removed

modified:cobra_test.go+5 added
753 unmodified lines
754755 if r.Output != s {756 t.Errorf("Unexpected response.\nExpecting to be:\n %q\nGot:\n %q\n", s, r.Output)757 }758759 r = noRRSetupTest("--strtwo=a bogus")760 if r.Output != s {761 t.Errorf("Unexpected response.\nExpecting to be:\n %q\nGot:\n %q\n", s, r.Output)762 }763}764765func TestFlagsBeforeCommand(t *testing.T) {766 // short without space
181 unmodified lines
modified:command.go+1 added-1 removed
422 unmodified lines
423 commandFound, a := innerfind(c, args)424425 // If we matched on the root, but we asked for a subcommand, return an error426 if commandFound.Name() == c.Name() && len(stripFlags(args, c)) > 0 && commandFound.Name() != args[0] {427 return nil, a, fmt.Errorf("unknown command %q", a[0])427 return nil, a, fmt.Errorf("unknown command %q", stripFlags(args, c)[0])428 }429430 return commandFound, a, nil431}
600 unmodified lines