diff --git a/cmd/ppass/ppass.go b/cmd/ppass/ppass.go index 758e779..d119c91 100644 --- a/cmd/ppass/ppass.go +++ b/cmd/ppass/ppass.go @@ -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)