-
Notifications
You must be signed in to change notification settings - Fork 0
/
root.go
42 lines (37 loc) · 1.47 KB
/
root.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package cmd
import (
"os"
"github.com/dejanzele/batch-simulator/cmd/simulator/config"
"github.com/dejanzele/batch-simulator/internal/logger"
"github.com/spf13/cobra"
)
// rootCmd represents the root command
var rootCmd = &cobra.Command{
Use: "batchsim",
Short: "kwok-based batch simulation tool",
Long: `This command-line interface (CLI) tool facilitates the simulation of batch scheduling scenarios,
leveraging Kubernetes (k8s) and Kwok technologies.
It's designed for users who need to model and understand various batch processing workflows within a k8s environment.`,
PersistentPreRun: func(cmd *cobra.Command, args []string) {
logger.Init(getLogLevel())
},
Run: func(cmd *cobra.Command, args []string) {
if Help(cmd, args) {
os.Exit(0)
}
},
}
func NewRootCmd() *cobra.Command {
rootCmd.PersistentFlags().BoolVarP(&config.Verbose, "verbose", "v", false, "enable verbose output")
rootCmd.PersistentFlags().BoolVarP(&config.Debug, "debug", "d", false, "enable debug output")
rootCmd.PersistentFlags().BoolVarP(&config.Silent, "silent", "s", false, "disable internal logging")
rootCmd.PersistentFlags().BoolVar(&config.NoGUI, "no-gui", false, "disable printing graphical elements")
rootCmd.AddCommand(NewCheckCmd())
rootCmd.AddCommand(NewInitCmd())
rootCmd.AddCommand(NewRemoveCmd())
rootCmd.AddCommand(NewRunCmd())
rootCmd.AddCommand(NewCleanCmd())
rootCmd.AddCommand(NewWatchCmd())
rootCmd.MarkFlagsMutuallyExclusive("verbose", "debug", "silent")
return rootCmd
}