🎨 大部分的 make 指令
This commit is contained in:
37
internal/cmd/root.go
Normal file
37
internal/cmd/root.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitea.loveuer.com/yizhisec/pkg3/logger"
|
||||
"github.com/spf13/cobra"
|
||||
"yizhisec.com/hsv2/forge/internal/opt"
|
||||
)
|
||||
|
||||
var rootCmd = &cobra.Command{
|
||||
Use: "forge",
|
||||
Short: "Forge is a tool for building and installing hsv2",
|
||||
Long: `A tool for managing build and installation workflows for hsv2.`,
|
||||
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
|
||||
if opt.Cfg.Debug {
|
||||
logger.SetLogLevel(logger.LogLevelDebug)
|
||||
logger.Warn("running in debug mode")
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
func Execute(ctx context.Context) error {
|
||||
return rootCmd.ExecuteContext(ctx)
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
||||
rootCmd.PersistentFlags().BoolVar(&opt.Cfg.Debug, "debug", false, "Enable debug mode")
|
||||
|
||||
rootCmd.AddCommand(
|
||||
makeCmd(),
|
||||
installCmd(),
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user