diff --git a/cmd/flags/config.go b/cmd/flags/config.go index e10deadc..ecb63ab9 100644 --- a/cmd/flags/config.go +++ b/cmd/flags/config.go @@ -6,8 +6,6 @@ var ( LogStd bool - ConfigFile string - SkipEnv bool SkipConfig bool diff --git a/cmd/root.go b/cmd/root.go index afacc2ce..43da85c8 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -40,7 +40,6 @@ func init() { home = "~" } RootCmd.PersistentFlags().StringVar(&flags.DataDir, "data-dir", filepath.Join(home, ".synctv"), "data dir") - RootCmd.PersistentFlags().StringVarP(&flags.ConfigFile, "config", "f", "", "config file path") } func init() { diff --git a/internal/bootstrap/config.go b/internal/bootstrap/config.go index c48c0aba..7988bf35 100644 --- a/internal/bootstrap/config.go +++ b/internal/bootstrap/config.go @@ -25,20 +25,16 @@ func InitConfig(ctx context.Context) (err error) { } conf.Conf = conf.DefaultConfig() if !flags.SkipConfig { - if flags.ConfigFile == "" { - flags.ConfigFile = filepath.Join(flags.DataDir, "config.yaml") - } else { - flags.ConfigFile, err = utils.OptFilePath(flags.ConfigFile) - if err != nil { - log.Fatalf("config file path error: %v", err) - } + configFile, err := utils.OptFilePath(filepath.Join(flags.DataDir, "config.yaml")) + if err != nil { + log.Fatalf("config file path error: %v", err) } - err = confFromConfig(flags.ConfigFile, conf.Conf) + err = confFromConfig(configFile, conf.Conf) if err != nil { log.Fatalf("load config from file error: %v", err) } - log.Infof("load config success from file: %s", flags.ConfigFile) - if err = restoreConfig(flags.ConfigFile, conf.Conf); err != nil { + log.Infof("load config success from file: %s", configFile) + if err = restoreConfig(configFile, conf.Conf); err != nil { log.Warnf("restore config error: %v", err) } else { log.Info("restore config success")