renaming configurations file to path in preparation for directory

This commit is contained in:
Baipyrus 2024-09-24 14:40:42 +02:00
parent a957fdcc8d
commit aa3dd46c57
8 changed files with 13 additions and 13 deletions

View File

@ -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)
},
}

View File

@ -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.

View File

@ -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)
}
},
}

View File

@ -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)
},
}

View File

@ -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)
},
}

View File

@ -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

View File

@ -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

View File

@ -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