README.md Readability Improvements (#1228)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
I made some small changes to the README.md file to enhance its readability.
authored by zaataylor · committed by GitHub · parent 08c51e5 · Browse files · 1 file·+10 added−10 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+10 added−10 removed
- other:+10 added−10 removed
Provenance
- Commit
39b5a91- Tree
dac3ca2- Author
zaataylor <40524990+zaataylor@users.noreply.github.com>- Committer
GitHub <noreply@github.com>- Parent
08c51e5
1 file changed+10 added−10 removed
modified:README.md+10 added-10 removed
60 unmodified lines61 Cobra is built on a structure of commands, arguments & flags.62 63 **Commands** represent actions, **Args** are things and **Flags** are modifiers for those actions.64 65-The best applications will read like sentences when used. Users will know how66-to use the application because they will natively understand how to use it.65+The best applications read like sentences when used, and as a result, users66+intuitively know how to interact with them.67 68 The pattern to follow is69 `APPNAME VERB NOUN --ADJECTIVE.`70 or196 unmodified lines267 268 With the root command you need to have your main function execute it.269 Execute should be run on the root for clarity, though it can be called on any command.270 271-In a Cobra app, typically the main.go file is very bare. It serves, one purpose, to initialize Cobra.271+In a Cobra app, typically the main.go file is very bare. It serves one purpose: to initialize Cobra.272 273 ```go274 package main275 86 unmodified lines362 There are two different approaches to assign a flag.363 364 ### Persistent Flags365 366-A flag can be 'persistent' meaning that this flag will be available to the366+A flag can be 'persistent', meaning that this flag will be available to the367 command it's assigned to as well as every command under that command. For368 global flags, assign a flag as a persistent flag on the root.369 370 ```go1 unmodified line372 ```373 374 ### Local Flags375 376-A flag can also be assigned locally which will only apply to that specific command.376+A flag can also be assigned locally, which will only apply to that specific command.377 378 ```go379 localCmd.Flags().StringVarP(&Source, "source", "s", "", "Source directory to read from")380 ```381 382 ### Local Flag on Parent Commands383 384-By default Cobra only parses local flags on the target command, any local flags on385-parent commands are ignored. By enabling `Command.TraverseChildren` Cobra will384+By default, Cobra only parses local flags on the target command, and any local flags on385+parent commands are ignored. By enabling `Command.TraverseChildren`, Cobra will386 parse local flags on each command before executing the target command.387 388 ```go389 command := cobra.Command{13 unmodified lines403 viper.BindPFlag("author", rootCmd.PersistentFlags().Lookup("author"))404 }405 ```406 407-In this example the persistent flag `author` is bound with `viper`.408-**Note**, that the variable `author` will not be set to the value from config,407+In this example, the persistent flag `author` is bound with `viper`.408+**Note**: the variable `author` will not be set to the value from config,409 when the `--author` flag is not provided by user.410 411 More in [viper documentation](https://github.com/spf13/viper#working-with-flags).412 51 unmodified lines464 ## Example465 466 In the example below, we have defined three commands. Two are at the top level467 and one (cmdTimes) is a child of one of the top commands. In this case the root468-is not executable meaning that a subcommand is required. This is accomplished468+is not executable, meaning that a subcommand is required. This is accomplished469 by not providing a 'Run' for the 'rootCmd'.470 471 We have only defined one flag for a single command.472 294 unmodified lines