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