feat: add /path command to change file save path and improve configuration handling

This commit is contained in:
krau
2025-02-15 16:25:16 +08:00
parent 8ba0c623c9
commit 5f3b38c788
2 changed files with 65 additions and 1 deletions

View File

@@ -121,3 +121,20 @@ func Init() {
os.Exit(1)
}
}
func Set(key string, value any) {
viper.Set(key, value)
}
func ReloadConfig() error {
if err := viper.WriteConfig(); err != nil {
return err
}
if err := viper.ReadInConfig(); err != nil {
return err
}
if error := viper.Unmarshal(Cfg); error != nil {
return error
}
return nil
}