|
|
@ -44,6 +44,10 @@ type App struct {
|
|
|
|
Action func(context *Context)
|
|
|
|
Action func(context *Context)
|
|
|
|
// Execute this function if the proper command cannot be found
|
|
|
|
// Execute this function if the proper command cannot be found
|
|
|
|
CommandNotFound func(context *Context, command string)
|
|
|
|
CommandNotFound func(context *Context, command string)
|
|
|
|
|
|
|
|
// Execute this function, if an usage error occurs. This is useful for displaying customized usage error messages.
|
|
|
|
|
|
|
|
// This function is able to replace the original error messages.
|
|
|
|
|
|
|
|
// If this function is not set, the "Incorrect usage" is displayed and the execution is interrupted.
|
|
|
|
|
|
|
|
OnUsageError func(context *Context, err error, isSubcommand bool) error
|
|
|
|
// Compilation date
|
|
|
|
// Compilation date
|
|
|
|
Compiled time.Time
|
|
|
|
Compiled time.Time
|
|
|
|
// List of all authors who contributed
|
|
|
|
// List of all authors who contributed
|
|
|
@ -131,9 +135,14 @@ func (a *App) Run(arguments []string) (err error) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
fmt.Fprintf(a.Writer, "%s\n\n", "Incorrect Usage.")
|
|
|
|
if a.OnUsageError != nil {
|
|
|
|
ShowAppHelp(context)
|
|
|
|
err := a.OnUsageError(context, err, false)
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
fmt.Fprintf(a.Writer, "%s\n\n", "Incorrect Usage.")
|
|
|
|
|
|
|
|
ShowAppHelp(context)
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if !a.HideHelp && checkHelp(context) {
|
|
|
|
if !a.HideHelp && checkHelp(context) {
|
|
|
@ -238,9 +247,14 @@ func (a *App) RunAsSubcommand(ctx *Context) (err error) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
fmt.Fprintf(a.Writer, "%s\n\n", "Incorrect Usage.")
|
|
|
|
if a.OnUsageError != nil {
|
|
|
|
ShowSubcommandHelp(context)
|
|
|
|
err = a.OnUsageError(context, err, true)
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
fmt.Fprintf(a.Writer, "%s\n\n", "Incorrect Usage.")
|
|
|
|
|
|
|
|
ShowSubcommandHelp(context)
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if len(a.Commands) > 0 {
|
|
|
|
if len(a.Commands) > 0 {
|
|
|
|