funcs.go 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package cli
  2. // BashCompleteFunc is an action to execute when the bash-completion flag is set
  3. type BashCompleteFunc func(*Context)
  4. // BeforeFunc is an action to execute before any subcommands are run, but after
  5. // the context is ready if a non-nil error is returned, no subcommands are run
  6. type BeforeFunc func(*Context) error
  7. // AfterFunc is an action to execute after any subcommands are run, but after the
  8. // subcommand has finished it is run even if Action() panics
  9. type AfterFunc func(*Context) error
  10. // ActionFunc is the action to execute when no subcommands are specified
  11. type ActionFunc func(*Context) error
  12. // CommandNotFoundFunc is executed if the proper command cannot be found
  13. type CommandNotFoundFunc func(*Context, string)
  14. // OnUsageErrorFunc is executed if an usage error occurs. This is useful for displaying
  15. // customized usage error messages. This function is able to replace the
  16. // original error messages. If this function is not set, the "Incorrect usage"
  17. // is displayed and the execution is interrupted.
  18. type OnUsageErrorFunc func(context *Context, err error, isSubcommand bool) error
  19. // ExitErrHandlerFunc is executed if provided in order to handle ExitError values
  20. // returned by Actions and Before/After functions.
  21. type ExitErrHandlerFunc func(context *Context, err error)
  22. // FlagStringFunc is used by the help generation to display a flag, which is
  23. // expected to be a single line.
  24. type FlagStringFunc func(Flag) string
  25. // FlagNamePrefixFunc is used by the default FlagStringFunc to create prefix
  26. // text for a flag's full name.
  27. type FlagNamePrefixFunc func(fullName, placeholder string) string
  28. // FlagEnvHintFunc is used by the default FlagStringFunc to annotate flag help
  29. // with the environment variable details.
  30. type FlagEnvHintFunc func(envVar, str string) string
  31. // FlagFileHintFunc is used by the default FlagStringFunc to annotate flag help
  32. // with the file path details.
  33. type FlagFileHintFunc func(filePath, str string) string