Divide fields of Command for readability
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Albert Nigmatzianov · committed by Albert Nigmatzianov · parent 90d2fd8 · Browse files · 1 file·+24 added−7 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+24 added−7 removed
- other:+24 added−7 removed
Provenance
- Commit
eceb483- Tree
ac26f0d- Author
Albert Nigmatzianov <albertnigma@gmail.com>- Committer
Albert Nigmatzianov <albertnigma@gmail.com>- Parent
90d2fd8
1 file changed+24 added−7 removed
modified:command.go+24 added-7 removed
30 unmodified lines31 // E.g. 'go run ...' - 'run' is the command. Cobra requires32 // you to define the usage and description as part of your command33 // definition to ensure usability.34 type Command struct {35- // name is the command name, usually the executable's name.36- name string35 // Use is the one-line usage message.36 Use string37+38 // Aliases is an array of aliases that can be used instead of the first word in Use.39 Aliases []string40+41 // SuggestFor is an array of command names for which this command will be suggested -42 // similar to aliases but only suggests.43 SuggestFor []string44+45 // Short is the short description shown in the 'help' output.46 Short string47+48 // Long is the long message shown in the 'help <this-command>' output.49 Long string50+51 // Example is examples of how to use the command.52 Example string53+54 // ValidArgs is list of all valid non-flag arguments that are accepted in bash completions55 ValidArgs []string56+57 // ArgAliases is List of aliases for ValidArgs.58 // These are not suggested to the user in the bash completion,59 // but accepted if entered manually.60 ArgAliases []string61+62 // BashCompletionFunction is custom functions used by the bash autocompletion generator.63 BashCompletionFunction string64+65 // Deprecated defines, if this command is deprecated and should print this string when used.66 Deprecated string67+68 // Hidden defines, if this command is hidden and should NOT show up in the list of available commands.69 Hidden bool70+71 // Annotations are key/value pairs that can be used by applications to identify or72 // group commands.73 Annotations map[string]string65- // SilenceErrors is an option to quiet errors down stream.66- SilenceErrors bool67- // Silence Usage is an option to silence usage when an error occurs.68- SilenceUsage bool74+75 // The *Run functions are executed in the following order:76 // * PersistentPreRun()77 // * PreRun()78 // * Run()79 // * PostRun()80 // * PersistentPostRun()81 // All functions get the same args, the arguments after the command name.82+ //83 // PersistentPreRun: children of this command will inherit and execute.84 PersistentPreRun func(cmd *Command, args []string)85 // PersistentPreRunE: PersistentPreRun but returns an error.86 PersistentPreRunE func(cmd *Command, args []string) error12 unmodified lines99 // PersistentPostRun: children of this command will inherit and execute after PostRun.100 PersistentPostRun func(cmd *Command, args []string)101 // PersistentPostRunE: PersistentPostRun but returns an error.102 PersistentPostRunE func(cmd *Command, args []string) error103+104+ // SilenceErrors is an option to quiet errors down stream.105+ SilenceErrors bool106+107+ // SilenceUsage is an option to silence usage when an error occurs.108+ SilenceUsage bool109+110 // DisableFlagParsing disables the flag parsing.111 // If this is true all flags will be passed to the command as arguments.112 DisableFlagParsing bool113+114 // DisableAutoGenTag defines, if gen tag ("Auto generated by spf13/cobra...")115 // will be printed by generating docs for this command.116 DisableAutoGenTag bool117 3 unmodified lines121 // SuggestionsMinimumDistance defines minimum levenshtein distance to display suggestions.122 // Must be > 0.123 SuggestionsMinimumDistance int124 125+ // name is the command name, usually the executable's name.126+ name string127 // commands is the list of commands supported by this program.128 commands []*Command129 // parent is a parent command for this command.130 parent *Command114- // max lengths of commands' string lengths for use in padding.131+ // Max lengths of commands' string lengths for use in padding.132 commandsMaxUseLen int133 commandsMaxCommandPathLen int134 commandsMaxNameLen int135 // commandsAreSorted defines, if command slice are sorted or not.1163 unmodified lines