first commit
This commit is contained in:
52
cmd/root.go
Normal file
52
cmd/root.go
Normal file
@@ -0,0 +1,52 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/spf13/cobra"
|
||||
"os"
|
||||
)
|
||||
|
||||
var (
|
||||
flagVerbose uint8
|
||||
flagWorkdir string
|
||||
)
|
||||
|
||||
var (
|
||||
flagAnsibleVerbose uint8
|
||||
flagAnsibleBin string
|
||||
flagGenOnly bool
|
||||
flagTargetHost string
|
||||
)
|
||||
|
||||
var rootCmd = &cobra.Command{
|
||||
Use: "playbookctl",
|
||||
Short: "Ansible Playbook Dedic2 Control",
|
||||
Version: "4.0",
|
||||
RunE: func(cmd *cobra.Command, _ []string) error {
|
||||
return cmd.Help()
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.PersistentFlags().Uint8Var(&flagVerbose, "verbose", 1, "verbose mode (0-3)")
|
||||
rootCmd.PersistentFlags().StringVar(&flagWorkdir, "workdir", ".", "рабочая директория")
|
||||
|
||||
if err := rootCmd.MarkPersistentFlagDirname("workdir"); err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
rootCmd.AddCommand(NewCommandSpace())
|
||||
rootCmd.AddCommand(NewCommandRole())
|
||||
rootCmd.AddCommand(NewCommandInstall())
|
||||
rootCmd.AddCommand(NewCommandHosts())
|
||||
rootCmd.AddCommand(NewCommandBackup())
|
||||
rootCmd.AddCommand(NewCommandRestore())
|
||||
}
|
||||
|
||||
func Execute() {
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user