mirror of https://github.com/spf13/cobra.git
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
|
@ -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 New Issue