From aa3dd46c5783c4fabbc755ac45b13b36d148cee0 Mon Sep 17 00:00:00 2001 From: Baipyrus Date: Tue, 24 Sep 2024 14:40:42 +0200 Subject: [PATCH] renaming configurations file to path in preparation for directory --- cmd/debug.go | 2 +- cmd/root.go | 4 ++-- cmd/save.go | 2 +- cmd/set.go | 2 +- cmd/unset.go | 2 +- proxy/debug.go | 6 +++--- proxy/set.go | 4 ++-- proxy/unset.go | 4 ++-- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/cmd/debug.go b/cmd/debug.go index e225a12..19299c4 100644 --- a/cmd/debug.go +++ b/cmd/debug.go @@ -10,7 +10,7 @@ var debugCmd = &cobra.Command{ Use: "debug", Short: "Output all parsed configurations for debugging", Run: func(cmd *cobra.Command, args []string) { - proxy.Debug(cfgFile) + proxy.Debug(cfgPath) }, } diff --git a/cmd/root.go b/cmd/root.go index 79589a3..c6dfe60 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -7,7 +7,7 @@ import ( ) var ( - cfgFile string + cfgPath string // rootCmd represents the base command when called without any subcommands rootCmd = &cobra.Command{ @@ -33,7 +33,7 @@ func init() { // Cobra supports persistent flags, which, if defined here, // will be global for your application. - rootCmd.PersistentFlags().StringVarP(&cfgFile, "configs", "c", "configs.json", "configurations file") + rootCmd.PersistentFlags().StringVarP(&cfgPath, "configs", "c", "configs/", "configurations path") // Cobra also supports local flags, which will only run // when this action is called directly. diff --git a/cmd/save.go b/cmd/save.go index 56f4e7a..83c994d 100644 --- a/cmd/save.go +++ b/cmd/save.go @@ -38,7 +38,7 @@ var saveCmd = &cobra.Command{ var input string fmt.Print("Save this data? (Y/n) ") if input == "" || strings.ToLower(input) == "y" { - util.SaveConfig(cfgFile, config) + util.SaveConfig(cfgPath, config) } }, } diff --git a/cmd/set.go b/cmd/set.go index 011ff22..1b0d49d 100644 --- a/cmd/set.go +++ b/cmd/set.go @@ -10,7 +10,7 @@ var setCmd = &cobra.Command{ Use: "set", Short: "Enable the current internet proxy settings", Run: func(cmd *cobra.Command, args []string) { - proxy.Set(cfgFile) + proxy.Set(cfgPath) }, } diff --git a/cmd/unset.go b/cmd/unset.go index c619448..d751baa 100644 --- a/cmd/unset.go +++ b/cmd/unset.go @@ -10,7 +10,7 @@ var unsetCmd = &cobra.Command{ Use: "unset", Short: "Disable the current internet proxy settings", Run: func(cmd *cobra.Command, args []string) { - proxy.Unset(cfgFile) + proxy.Unset(cfgPath) }, } diff --git a/proxy/debug.go b/proxy/debug.go index 9db4400..45a12c2 100644 --- a/proxy/debug.go +++ b/proxy/debug.go @@ -22,8 +22,8 @@ func mapCmdsToStr(commands []*util.Command) string { return strings.Join(output, "\n") } -func Debug(cfgFile string) { - path, _ := filepath.Abs(cfgFile) +func Debug(cfgPath string) { + path, _ := filepath.Abs(cfgPath) if _, err := os.Stat(path); errors.Is(err, os.ErrNotExist) { path = "[N/A]" } @@ -41,7 +41,7 @@ func Debug(cfgFile string) { fmt.Printf("Enabled: %t\n", proxy.Enabled) fmt.Printf("Server: %s\n\n", proxyServer) - configs, _ := util.ReadConfigs(cfgFile) + configs, _ := util.ReadConfigs(cfgPath) for _, config := range configs { configCmd := config.Name // Use command instead of name, if given diff --git a/proxy/set.go b/proxy/set.go index a531657..4621165 100644 --- a/proxy/set.go +++ b/proxy/set.go @@ -4,7 +4,7 @@ import ( "github.com/Baipyrus/ProxySwitcher/util" ) -func Set(cfgFile string) { +func Set(cfgPath string) { stdin, closeFunc, _ := util.ReadyCmd() proxy, _ := ReadSystemProxy() @@ -13,7 +13,7 @@ func Set(cfgFile string) { SetSystemProxy(true) } - configs, _ := util.ReadConfigs(cfgFile) + configs, _ := util.ReadConfigs(cfgPath) for _, config := range configs { configCmd := config.Name // Use command instead of name, if given diff --git a/proxy/unset.go b/proxy/unset.go index c24b4b8..425c41f 100644 --- a/proxy/unset.go +++ b/proxy/unset.go @@ -4,7 +4,7 @@ import ( "github.com/Baipyrus/ProxySwitcher/util" ) -func Unset(cfgFile string) { +func Unset(cfgPath string) { stdin, closeFunc, _ := util.ReadyCmd() proxy, _ := ReadSystemProxy() @@ -13,7 +13,7 @@ func Unset(cfgFile string) { SetSystemProxy(false) } - configs, _ := util.ReadConfigs(cfgFile) + configs, _ := util.ReadConfigs(cfgPath) for _, config := range configs { configCmd := config.Name // Use command instead of name, if given