options: Add kong.ShortUsageOnError() option
Add kong.ShortUsageOnError() option similar to kong.UsageOnError().
Add tests for UsageOnError and ShortUsageOnError.
Remove the HelpOption summary reset at the beginning of DefaultHelpPrinter:
func DefaultHelpPrinter(options HelpOptions, ctx *Context) error {
- if ctx.Empty() {
- options.Summary = false
- }
⚠️ I'm not really sure what the implications of this are, tests still
seem to pass, but maybe this has unintended side effects.
This commit is contained in:
@@ -87,6 +87,21 @@ func DefaultHelpValueFormatter(value *Value) string {
|
||||
}
|
||||
}
|
||||
|
||||
// DefaultShortHelpPrinter is the default HelpPrinter for short help on error.
|
||||
func DefaultShortHelpPrinter(options HelpOptions, ctx *Context) error {
|
||||
w := newHelpWriter(ctx, options)
|
||||
cmd := ctx.Selected()
|
||||
app := ctx.Model
|
||||
if cmd == nil {
|
||||
w.Printf("Usage: %s%s", app.Name, app.Summary())
|
||||
w.Printf(`Run "%s --help" for more information.`, app.Name)
|
||||
} else {
|
||||
w.Printf("Usage: %s %s", app.Name, cmd.Summary())
|
||||
w.Printf(`Run "%s --help" for more information.`, cmd.FullPath())
|
||||
}
|
||||
return w.Write(ctx.Stdout)
|
||||
}
|
||||
|
||||
// DefaultHelpPrinter is the default HelpPrinter.
|
||||
func DefaultHelpPrinter(options HelpOptions, ctx *Context) error {
|
||||
if ctx.Empty() {
|
||||
|
||||
Reference in New Issue
Block a user