40 lines
1.4 KiB
Go
40 lines
1.4 KiB
Go
package control
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/spf13/cobra"
|
|
"gitea.sunhpc.com/kelvin/sunhpc/internal/app/control/version"
|
|
"gitea.sunhpc.com/kelvin/sunhpc/internal/pkg/help"
|
|
"gitea.sunhpc.com/kelvin/sunhpc/internal/pkg/splog"
|
|
)
|
|
|
|
var (
|
|
rootCmd = &cobra.Command{
|
|
DisableFlagsInUseLine: true,
|
|
Use: "sunhpc control COMMAND [options] [FLAGS]",
|
|
Short: "Sunhpc Control",
|
|
Long: `Control interface to the SunHPC Cluster Provisioning System.`,
|
|
PersistentPreRunE: rootPersistentPreRunE,
|
|
SilenceUsage: true,
|
|
SilenceErrors: true,
|
|
Args: cobra.NoArgs,
|
|
}
|
|
verboseArg bool
|
|
DebugFlag bool
|
|
SunhpcConfArg string
|
|
AllowEmptyConf bool
|
|
)
|
|
|
|
func init() {
|
|
rootCmd.CompletionOptions.HiddenDefaultCmd = true
|
|
rootCmd.PersistentFlags().BoolVarP(&verboseArg, "verbose", "v", false, "verbose output")
|
|
rootCmd.PersistentFlags().BoolVarP(&DebugFlag, "debug", "d", false, "debug output")
|
|
rootCmd.PersistentFlags().IntVar(&LogLevel, "loglevel", splog.INFO, "Set log level to given string")
|
|
_ = rootCmd.PersistentFlags().MarkHidden("loglevel")
|
|
rootCmd.PersistentFlags().StringVar(&SunhpcConfArg, "sunhpcconf", "", "Set the sunhpc configuration file")
|
|
rootCmd.PersistentFlags().BoolVar(&AllowEmptyConf, "emptyconf", false, "Allow empty configuration")
|
|
_ = rootCmd.PersistentFlags().MarkHidden("emptyconf")
|
|
rootCmd.SetUsageTemplate(help.UsageTemplate)
|
|
rootCmd.SetHelpTemplate(help.HelpTemplate)
|
|
} |