Commit 0e2607e1 authored by Janos Guljas's avatar Janos Guljas

fix global flags parsing

parent ec9ddf2b
......@@ -34,6 +34,9 @@ func newCommand(opts ...option) (c *command, err error) {
Short: "Ethereum Swarm Bee",
SilenceErrors: true,
SilenceUsage: true,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
return c.initConfig()
},
},
}
......@@ -42,9 +45,6 @@ func newCommand(opts ...option) (c *command, err error) {
}
c.initGlobalFlags()
if err := c.initConfig(); err != nil {
return nil, err
}
if err := c.initStartCmd(); err != nil {
return nil, err
......
......@@ -141,6 +141,9 @@ func (c *command) initStartCmd() (err error) {
return nil
},
PreRunE: func(cmd *cobra.Command, args []string) error {
return c.config.BindPFlags(cmd.Flags())
},
}
cmd.Flags().String(optionNameDataDir, filepath.Join(c.homeDir, ".bee"), "data directory")
......@@ -157,10 +160,6 @@ func (c *command) initStartCmd() (err error) {
cmd.Flags().Duration(optionNameConnectionsGrace, time.Minute, "the amount of time a newly opened connection is given before it becomes subject to pruning")
cmd.Flags().String(optionNameVerbosity, "info", "log verbosity level 0=silent, 1=error, 2=warn, 3=info, 4=debug, 5=trace")
if err := c.config.BindPFlags(cmd.Flags()); err != nil {
return err
}
c.root.AddCommand(cmd)
return nil
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment