bugfix: monitor variables were dependent on order in which commands were initialized inside on init(). Using PreRun we can control the value per command called by having the function run only when the function is executed.
This commit is contained in:
parent
fee20090d0
commit
d1097f33ac
3 changed files with 40 additions and 16 deletions
23
cmd/docs.go
23
cmd/docs.go
|
@ -1,24 +1,23 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/cobra/doc"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/cobra/doc"
|
||||
)
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(docsCmd)
|
||||
rootCmd.AddCommand(docsCmd)
|
||||
}
|
||||
|
||||
var docsCmd = &cobra.Command{
|
||||
Use: "docs",
|
||||
Short: "Kill an Aurora Job",
|
||||
Use: "docs",
|
||||
Short: "Kill an Aurora Job",
|
||||
PersistentPreRun: func(cmd *cobra.Command, args []string) {}, // We don't need a realis client for this cmd
|
||||
PersistentPostRun: func(cmd *cobra.Command, args []string) {}, // We don't need a realis client for this cmd
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
err := doc.GenMarkdownTree(rootCmd, "./docs")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
},
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
err := doc.GenMarkdownTree(rootCmd, "./docs")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue