From 817a14704b827e01da93dbaf558732ce0c871069 Mon Sep 17 00:00:00 2001 From: kalipso Date: Thu, 10 Oct 2024 14:16:21 +0200 Subject: [PATCH] ppass handle debug flag --- cmd/ppass/ppass.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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)