Command contains everything needed to run an application that accepts a string slice of arguments such as os.Args. A given Command may contain Flags and sub-commands in Commands.
| 21 | // accepts a string slice of arguments such as os.Args. A given |
| 22 | // Command may contain Flags and sub-commands in Commands. |
| 23 | type Command struct { |
| 24 | // The name of the command |
| 25 | Name string `json:"name"` |
| 26 | // A list of aliases for the command |
| 27 | Aliases []string `json:"aliases"` |
| 28 | // A short description of the usage of this command |
| 29 | Usage string `json:"usage"` |
| 30 | // Text to override the USAGE section of help |
| 31 | UsageText string `json:"usageText"` |
| 32 | // A short description of the arguments of this command |
| 33 | ArgsUsage string `json:"argsUsage"` |
| 34 | // Version of the command |
| 35 | Version string `json:"version"` |
| 36 | // Longer explanation of how the command works |
| 37 | Description string `json:"description"` |
| 38 | // DefaultCommand is the (optional) name of a command |
| 39 | // to run if no command names are passed as CLI arguments. |
| 40 | DefaultCommand string `json:"defaultCommand"` |
| 41 | // The category the command is part of |
| 42 | Category string `json:"category"` |
| 43 | // List of child commands |
| 44 | Commands []*Command `json:"commands"` |
| 45 | // List of flags to parse |
| 46 | Flags []Flag `json:"flags"` |
| 47 | // Boolean to hide built-in help command and help flag |
| 48 | HideHelp bool `json:"hideHelp"` |
| 49 | // Ignored if HideHelp is true. |
| 50 | HideHelpCommand bool `json:"hideHelpCommand"` |
| 51 | // Boolean to hide built-in version flag and the VERSION section of help |
| 52 | HideVersion bool `json:"hideVersion"` |
| 53 | // Boolean to enable shell completion commands |
| 54 | EnableShellCompletion bool `json:"-"` |
| 55 | // Shell Completion generation command name |
| 56 | ShellCompletionCommandName string `json:"-"` |
| 57 | // The function to call when checking for shell command completions |
| 58 | ShellComplete ShellCompleteFunc `json:"-"` |
| 59 | // The function to configure a shell completion command |
| 60 | ConfigureShellCompletionCommand ConfigureShellCompletionCommand `json:"-"` |
| 61 | // An action to execute before any subcommands are run, but after the context is ready |
| 62 | // If a non-nil error is returned, no subcommands are run |
| 63 | Before BeforeFunc `json:"-"` |
| 64 | // An action to execute after any subcommands are run, but after the subcommand has finished |
| 65 | // It is run even if Action() panics |
| 66 | After AfterFunc `json:"-"` |
| 67 | // The function to call when this command is invoked |
| 68 | Action ActionFunc `json:"-"` |
| 69 | // Execute this function if the proper command cannot be found |
| 70 | CommandNotFound CommandNotFoundFunc `json:"-"` |
| 71 | // Execute this function if a usage error occurs. |
| 72 | OnUsageError OnUsageErrorFunc `json:"-"` |
| 73 | // Execute this function when an invalid flag is accessed from the context |
| 74 | InvalidFlagAccessHandler InvalidFlagAccessFunc `json:"-"` |
| 75 | // Boolean to hide this command from help or completion |
| 76 | Hidden bool `json:"hidden"` |
| 77 | // List of all authors who contributed (string or fmt.Stringer) |
| 78 | // TODO: ~string | fmt.Stringer when interface unions are available |
| 79 | Authors []any `json:"authors"` |
| 80 | // Copyright of the binary if any |
nothing calls this directly
no outgoing calls
no test coverage detected