Addressing typos identified by @marckhouzam
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Steve Francia · committed by Steve Francia · parent 2682562 · Browse files · 1 file·+5 added−5 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+5 added−5 removed
- other:+5 added−5 removed
Provenance
- Commit
bfacc59- Tree
e9643be- Author
Steve Francia <steve.francia@gmail.com>- Committer
Steve Francia <steve.francia@gmail.com>- Parent
2682562
1 file changed+5 added−5 removed
modified:cobra/README.md+5 added-5 removed
7 unmodified lines89101112121314151626 unmodified lines4344454647474849505119 unmodified lines717273747575767778798 unmodified lines888990919292939495969798989910010110277 unmodified lines7 unmodified lines
Once installed you should have the `cobra` command available. Confirm by typing `cobra` at a command line.
There are only two operations currently supported by Cobra generator: There are only two operations currently supported by the Cobra generator:
### cobra init
The `cobra init [app]` command will create your initial application code26 unmodified lines
From within a Go module run `cobra init`. This will create a new barebones projectfor you to edit.
You should be able to run you new application immediately. Try it with You should be able to run your new application immediately. Try it with `go run main.go`.
You will want to open up and edit 'cmd/root.go' and provide your own description and logic.
19 unmodified linesViper is a companion to Cobra intended to provide easy handling of environment variables and config files and seamlessly connecting them to the application flags.
### Add commands to a project
Once a cobra application is initialized you can continue to use cobra generator to Once a cobra application is initialized you can continue to use the Cobra generator to add additional commands to your application. The command to do this is `cobra add`.
Let's say you created an app and you wanted the following commands for it:
8 unmodified linescobra add configcobra add create -p 'configCmd'```
`cobra add` supports all the same optional flags as `cobra init` does mentioned above.`cobra add` supports all the same optional flags as `cobra init` does (described above).
You'll notice that this final command has a `-p` flag. This is used to assign aparent command to the newly added command. In this case, we want to assign the"create" command to the "config" command. All commands have a default parent of rootCmd if not specified.
By default `cobra` will append `Cmd` to the name provided and uses this to name for the internal variable name. When specifying a parent, be sure to match the variable name used in the code. By default `cobra` will append `Cmd` to the name provided and uses this name for the internal variable name. When specifying a parent, be sure to match the variable name used in the code.
*Note: Use camelCase (not snake_case/kebab-case) for command names.Otherwise, you will encounter errors.For example, `cobra add add-user` is incorrect, but `cobra add addUser` is valid.*77 unmodified lines