mirror of
https://github.com/m1k1o/neko.git
synced 2025-08-06 10:20:26 +02:00
config flag with -c.
This commit is contained in:
parent
646b6ecaff
commit
499256492a
1 changed files with 5 additions and 5 deletions
|
@ -6,9 +6,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Root struct {
|
type Root struct {
|
||||||
Debug bool
|
Debug bool
|
||||||
Logs bool
|
Logs bool
|
||||||
CfgFile string
|
Config string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (Root) Init(cmd *cobra.Command) error {
|
func (Root) Init(cmd *cobra.Command) error {
|
||||||
|
@ -22,7 +22,7 @@ func (Root) Init(cmd *cobra.Command) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.PersistentFlags().String("config", "", "configuration file path")
|
cmd.PersistentFlags().StringP("config", "c", "", "configuration file path")
|
||||||
if err := viper.BindPFlag("config", cmd.PersistentFlags().Lookup("config")); err != nil {
|
if err := viper.BindPFlag("config", cmd.PersistentFlags().Lookup("config")); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -33,5 +33,5 @@ func (Root) Init(cmd *cobra.Command) error {
|
||||||
func (s *Root) Set() {
|
func (s *Root) Set() {
|
||||||
s.Logs = viper.GetBool("logs")
|
s.Logs = viper.GetBool("logs")
|
||||||
s.Debug = viper.GetBool("debug")
|
s.Debug = viper.GetBool("debug")
|
||||||
s.CfgFile = viper.GetString("config")
|
s.Config = viper.GetString("config")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue