wip: cli
This commit is contained in:
29
internal/cmd/root.go
Normal file
29
internal/cmd/root.go
Normal file
@ -0,0 +1,29 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/loveuer/nf/nft/log"
|
||||
"github.com/spf13/cobra"
|
||||
"ultone/internal/opt"
|
||||
)
|
||||
|
||||
func initRoot() {
|
||||
rootCommand.PersistentFlags().BoolVar(&opt.Debug, "debug", false, "debug mode")
|
||||
rootCommand.PersistentFlags().StringVarP(&filename, "config", "c", "etc/config.json", "config json file path")
|
||||
rootCommand.PersistentPreRun = func(cmd *cobra.Command, args []string) {
|
||||
if opt.Debug {
|
||||
log.SetLogLevel(log.LogLevelDebug)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
rootCommand.AddCommand(cliCommand)
|
||||
}
|
||||
|
||||
var (
|
||||
rootCommand = &cobra.Command{
|
||||
Use: "nf-app",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return execute(cmd.Context())
|
||||
},
|
||||
}
|
||||
)
|
Reference in New Issue
Block a user