Skip to content
Open
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
3 changes: 2 additions & 1 deletion subcommands.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func (cdr *Commander) countTopFlags() int {
// Execute should be called once the top-level-flags on a Commander
// have been initialized. It finds the correct subcommand and executes
// it, and returns an ExitStatus with the result. On a usage error, an
// appropriate message is printed to os.Stderr, and ExitUsageError is
// appropriate message is printed to *Commander.Error, and ExitUsageError is
// returned. The additional args are provided as-is to the Execute method
// of the selected Command.
func (cdr *Commander) Execute(ctx context.Context, args ...interface{}) ExitStatus {
Expand All @@ -201,6 +201,7 @@ func (cdr *Commander) Execute(ctx context.Context, args ...interface{}) ExitStat
continue
}
f := flag.NewFlagSet(name, flag.ContinueOnError)
f.SetOutput(cdr.Error)
f.Usage = func() { cdr.ExplainCommand(cdr.Error, cmd) }
cmd.SetFlags(f)
if f.Parse(cdr.topFlags.Args()[1:]) != nil {
Expand Down