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
Provenance
- Commit
7e289f4- Tree
7f13d53- Author
Marc Khouzam <marc.khouzam@gmail.com>- Committer
GitHub <noreply@github.com>- Parent
fe08012
2 files changed+17 added−14 removed
modified:README.md+2 added-2 removed
38 unmodified lines3940414243434445454647484962 unmodified lines38 unmodified linesThe best applications read like sentences when used, and as a result, usersintuitively know how to interact with them.
The pattern to follow is`APPNAME VERB NOUN --ADJECTIVE.``APPNAME VERB NOUN --ADJECTIVE` or`APPNAME COMMAND ARG --FLAG``APPNAME COMMAND ARG --FLAG`.
A few good real world examples may better illustrate this point.
In the following example, 'server' is a command, and 'port' is a flag:62 unmodified linesmodified:user_guide.md+15 added-12 removed
460 unmodified lines461 462 The following output is automatically generated by Cobra. Nothing beyond the463 command and flag definitions are needed.464 465- $ cobra help465+ $ cobra-cli help466 467 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.470 471 Usage:472- cobra [command]472+ cobra-cli [command]473 474 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 Application479 480 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 configuration486 486- Use "cobra [command] --help" for more information about a command.487+ Use "cobra-cli [command] --help" for more information about a command.488 489 490 Help is just a command like any other. There is no special logic or behavior491 around it. In fact, you can provide your own if you want.492 493 ### Defining your own help494 495 You can provide your own Help command or your own template for the default command to use495-with following functions:496+with the following functions:497 498 ```go499 cmd.SetHelpCommand(cmd *Command)500 cmd.SetHelpFunc(f func(*Command, []string))10 unmodified lines511 ### Example512 You may recognize this from the help above. That's because the default help513 embeds the usage as part of its output.514 514- $ cobra --invalid515+ $ cobra-cli --invalid516 Error: unknown flag: --invalid517 Usage:517- cobra [command]518+ cobra-cli [command]519 520 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 Application525 526 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 configuration532 533 Use "cobra [command] --help" for more information about a command.534 535 ### Defining your own usage110 unmodified lines646 647 Run 'hugo --help' for usage.648 ```649 648-Suggestions 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.650+Suggestions 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.651 652 If you need to disable suggestions or tweak the string distance in your command, use:653 654 ```go5 unmodified lines660 ```go661 command.SuggestionsMinimumDistance = 1662 ```663 662-You 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:664+You 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 which665+you don't want aliases. Example:666 667 ```668 $ kubectl remove669 Error: unknown command "remove" for "kubectl"18 unmodified lines