Skip to content
Myr

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

1 file+24 added−7 removed

modified:command.go+24 added-7 removed
30 unmodified lines
31// 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.34type 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 string3738 // Aliases is an array of aliases that can be used instead of the first word in Use.39 Aliases []string4041 // SuggestFor is an array of command names for which this command will be suggested -42 // similar to aliases but only suggests.43 SuggestFor []string4445 // Short is the short description shown in the 'help' output.46 Short string4748 // Long is the long message shown in the 'help <this-command>' output.49 Long string5051 // Example is examples of how to use the command.52 Example string5354 // ValidArgs is list of all valid non-flag arguments that are accepted in bash completions55 ValidArgs []string5657 // 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 []string6162 // BashCompletionFunction is custom functions used by the bash autocompletion generator.63 BashCompletionFunction string6465 // Deprecated defines, if this command is deprecated and should print this string when used.66 Deprecated string6768 // Hidden defines, if this command is hidden and should NOT show up in the list of available commands.69 Hidden bool7071 // 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 bool7475 // 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) error
12 unmodified lines
99 // 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) error103104 // SilenceErrors is an option to quiet errors down stream.105 SilenceErrors bool106107 // SilenceUsage is an option to silence usage when an error occurs.108 SilenceUsage bool109110 // DisableFlagParsing disables the flag parsing.111 // If this is true all flags will be passed to the command as arguments.112 DisableFlagParsing bool113114 // 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 lines
121 // SuggestionsMinimumDistance defines minimum levenshtein distance to display suggestions.122 // Must be > 0.123 SuggestionsMinimumDistance int124125 // 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