mirror of
https://github.com/m1k1o/neko.git
synced 2025-05-13 17:17:35 +02:00
add v2 compatible config.
This commit is contained in:
parent
b5c3f8d4a6
commit
e0a4b39cd5
10 changed files with 889 additions and 0 deletions
|
@ -30,6 +30,18 @@ func (Config) Init(cmd *cobra.Command) error {
|
|||
return err
|
||||
}
|
||||
|
||||
// v2 config
|
||||
|
||||
cmd.PersistentFlags().Bool("file_transfer_enabled", false, "enable file transfer feature")
|
||||
if err := viper.BindPFlag("file_transfer_enabled", cmd.PersistentFlags().Lookup("file_transfer_enabled")); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cmd.PersistentFlags().String("file_transfer_path", "", "path to use for file transfer")
|
||||
if err := viper.BindPFlag("file_transfer_path", cmd.PersistentFlags().Lookup("file_transfer_path")); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -38,4 +50,14 @@ func (s *Config) Set() {
|
|||
rootDir := viper.GetString("filetransfer.dir")
|
||||
s.RootDir = filepath.Clean(rootDir)
|
||||
s.RefreshInterval = viper.GetDuration("filetransfer.refresh_interval")
|
||||
|
||||
// v2 config
|
||||
|
||||
if viper.IsSet("file_transfer_enabled") {
|
||||
s.Enabled = viper.GetBool("file_transfer_enabled")
|
||||
}
|
||||
if viper.IsSet("file_transfer_path") {
|
||||
rootDir = viper.GetString("file_transfer_path")
|
||||
s.RootDir = filepath.Clean(rootDir)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue