mirror of
https://github.com/spf13/cobra
synced 2024-11-24 14:47:12 +00:00
Add Execute func example in README.md (#629)
Trivial addition to the first example in `README.md` that defines the `cmd.Execute()` function that is referenced further down in the `main.go` example.
This commit is contained in:
parent
c2bbfaa12d
commit
93959269ad
1 changed files with 7 additions and 0 deletions
|
@ -192,6 +192,13 @@ var rootCmd = &cobra.Command{
|
||||||
// Do Stuff Here
|
// Do Stuff Here
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Execute() {
|
||||||
|
if err := rootCmd.Execute(); err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
You will additionally define flags and handle configuration in your init() function.
|
You will additionally define flags and handle configuration in your init() function.
|
||||||
|
|
Loading…
Reference in a new issue