Skip to content
Myr

Adjustments to documentation (#1656)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Marc Khouzam · committed by GitHub · parent fe08012 · Browse files · 2 files+17 added−14 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>

Diff stats

2 files+17 added−14 removed

  • other:+17 added−14 removed

2 files+17 added−14 removed

modified:README.md+2 added-2 removed
modified:user_guide.md+15 added-12 removed
460 unmodified lines
461462The following output is automatically generated by Cobra. Nothing beyond the463command and flag definitions are needed.464465 $ cobra help465 $ cobra-cli help466467 Cobra is a CLI library for Go that empowers applications.468 This application is a tool to generate the needed files469 to quickly create a Cobra application.470471 Usage:472 cobra [command]472 cobra-cli [command]473474 Available Commands:475 add Add a command to a Cobra Application476 completion Generate the autocompletion script for the specified shell477 help Help about any command478 init Initialize a Cobra Application479480 Flags:481 -a, --author string author name for copyright attribution (default "YOUR NAME")482 --config string config file (default is $HOME/.cobra.yaml)482 -h, --help help for cobra483 -h, --help help for cobra-cli484 -l, --license string name of license for the project484 --viper use Viper for configuration (default true)485 --viper use Viper for configuration486486 Use "cobra [command] --help" for more information about a command.487 Use "cobra-cli [command] --help" for more information about a command.488489490Help is just a command like any other. There is no special logic or behavior491around it. In fact, you can provide your own if you want.492493### Defining your own help494495You can provide your own Help command or your own template for the default command to use495with following functions:496with the following functions:497498```go499cmd.SetHelpCommand(cmd *Command)500cmd.SetHelpFunc(f func(*Command, []string))
10 unmodified lines
511### Example512You may recognize this from the help above. That's because the default help513embeds the usage as part of its output.514514 $ cobra --invalid515 $ cobra-cli --invalid516 Error: unknown flag: --invalid517 Usage:517 cobra [command]518 cobra-cli [command]519520 Available Commands:521 add Add a command to a Cobra Application522 completion Generate the autocompletion script for the specified shell523 help Help about any command524 init Initialize a Cobra Application525526 Flags:527 -a, --author string author name for copyright attribution (default "YOUR NAME")528 --config string config file (default is $HOME/.cobra.yaml)527 -h, --help help for cobra529 -h, --help help for cobra-cli530 -l, --license string name of license for the project529 --viper use Viper for configuration (default true)531 --viper use Viper for configuration532533 Use "cobra [command] --help" for more information about a command.534535### Defining your own usage
110 unmodified lines
646647Run 'hugo --help' for usage.648```649648Suggestions are automatic based on every subcommand registered and use an implementation of [Levenshtein distance](https://en.wikipedia.org/wiki/Levenshtein_distance). Every registered command that matches a minimum distance of 2 (ignoring case) will be displayed as a suggestion.650Suggestions are automatically generated based on existing subcommands and use an implementation of [Levenshtein distance](https://en.wikipedia.org/wiki/Levenshtein_distance). Every registered command that matches a minimum distance of 2 (ignoring case) will be displayed as a suggestion.651652If you need to disable suggestions or tweak the string distance in your command, use:653654```go
5 unmodified lines
660```go661command.SuggestionsMinimumDistance = 1662```663662You can also explicitly set names for which a given command will be suggested using the `SuggestFor` attribute. This allows suggestions for strings that are not close in terms of string distance, but makes sense in your set of commands and for some which you don't want aliases. Example:664You can also explicitly set names for which a given command will be suggested using the `SuggestFor` attribute. This allows suggestions for strings that are not close in terms of string distance, but make sense in your set of commands but for which665you don't want aliases. Example:666667```668$ kubectl remove669Error: unknown command "remove" for "kubectl"
18 unmodified lines