mirror of https://github.com/docker/cli.git
Merge pull request #5233 from thaJeztah/nicer_errors
cli: FlagErrorFunc: don't print long usage output for invalid flags
This commit is contained in:
commit
05a808166b
|
@ -92,12 +92,8 @@ func FlagErrorFunc(cmd *cobra.Command, err error) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
usage := ""
|
||||
if cmd.HasSubCommands() {
|
||||
usage = "\n\n" + cmd.UsageString()
|
||||
}
|
||||
return StatusError{
|
||||
Status: fmt.Sprintf("%s\nSee '%s --help'.%s", err, cmd.CommandPath(), usage),
|
||||
Status: fmt.Sprintf("%s\n\nUsage: %s\n\nRun '%s --help' for more information", err, cmd.UseLine(), cmd.CommandPath()),
|
||||
StatusCode: 125,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,6 +78,6 @@ func TestGlobalHelp(t *testing.T) {
|
|||
})
|
||||
assert.Assert(t, is.Equal(res2.Stdout(), ""))
|
||||
assert.Assert(t, is.Contains(res2.Stderr(), "unknown flag: --badopt"))
|
||||
assert.Assert(t, is.Contains(res2.Stderr(), "See 'docker --help"))
|
||||
assert.Assert(t, is.Contains(res2.Stderr(), "Run 'docker --help' for more information"))
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue