ppass handle debug flag
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
||||
|
||||
var (
|
||||
dbPath = flag.String("db", "./db", "db file path")
|
||||
debug bool
|
||||
)
|
||||
|
||||
// Create the root command
|
||||
@@ -342,6 +343,7 @@ var deleteCmd = &cobra.Command{
|
||||
|
||||
func init() {
|
||||
rootCmd.PersistentFlags().String("db", "", "db path")
|
||||
rootCmd.PersistentFlags().BoolVar(&debug, "debug", false, "enable debug mode")
|
||||
rootCmd.MarkPersistentFlagRequired("db")
|
||||
|
||||
peerCmd.AddCommand(addPeerCmd)
|
||||
@@ -361,7 +363,7 @@ func init() {
|
||||
}
|
||||
|
||||
func main() {
|
||||
InitLogger(false)
|
||||
cobra.OnInitialize(func() { InitLogger(debug) })
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
Logger.Error(err)
|
||||
os.Exit(1)
|
||||
|
||||
Reference in New Issue
Block a user