mirror of
https://github.com/Baipyrus/ProxySwitcher.git
synced 2024-12-26 12:41:45 +00:00
renaming configurations file to path in preparation for directory
This commit is contained in:
parent
a957fdcc8d
commit
aa3dd46c57
@ -10,7 +10,7 @@ var debugCmd = &cobra.Command{
|
|||||||
Use: "debug",
|
Use: "debug",
|
||||||
Short: "Output all parsed configurations for debugging",
|
Short: "Output all parsed configurations for debugging",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
proxy.Debug(cfgFile)
|
proxy.Debug(cfgPath)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
cfgFile string
|
cfgPath string
|
||||||
|
|
||||||
// rootCmd represents the base command when called without any subcommands
|
// rootCmd represents the base command when called without any subcommands
|
||||||
rootCmd = &cobra.Command{
|
rootCmd = &cobra.Command{
|
||||||
@ -33,7 +33,7 @@ func init() {
|
|||||||
// Cobra supports persistent flags, which, if defined here,
|
// Cobra supports persistent flags, which, if defined here,
|
||||||
// will be global for your application.
|
// 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
|
// Cobra also supports local flags, which will only run
|
||||||
// when this action is called directly.
|
// when this action is called directly.
|
||||||
|
@ -38,7 +38,7 @@ var saveCmd = &cobra.Command{
|
|||||||
var input string
|
var input string
|
||||||
fmt.Print("Save this data? (Y/n) ")
|
fmt.Print("Save this data? (Y/n) ")
|
||||||
if input == "" || strings.ToLower(input) == "y" {
|
if input == "" || strings.ToLower(input) == "y" {
|
||||||
util.SaveConfig(cfgFile, config)
|
util.SaveConfig(cfgPath, config)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ var setCmd = &cobra.Command{
|
|||||||
Use: "set",
|
Use: "set",
|
||||||
Short: "Enable the current internet proxy settings",
|
Short: "Enable the current internet proxy settings",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
proxy.Set(cfgFile)
|
proxy.Set(cfgPath)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ var unsetCmd = &cobra.Command{
|
|||||||
Use: "unset",
|
Use: "unset",
|
||||||
Short: "Disable the current internet proxy settings",
|
Short: "Disable the current internet proxy settings",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
proxy.Unset(cfgFile)
|
proxy.Unset(cfgPath)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,8 +22,8 @@ func mapCmdsToStr(commands []*util.Command) string {
|
|||||||
return strings.Join(output, "\n")
|
return strings.Join(output, "\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
func Debug(cfgFile string) {
|
func Debug(cfgPath string) {
|
||||||
path, _ := filepath.Abs(cfgFile)
|
path, _ := filepath.Abs(cfgPath)
|
||||||
if _, err := os.Stat(path); errors.Is(err, os.ErrNotExist) {
|
if _, err := os.Stat(path); errors.Is(err, os.ErrNotExist) {
|
||||||
path = "[N/A]"
|
path = "[N/A]"
|
||||||
}
|
}
|
||||||
@ -41,7 +41,7 @@ func Debug(cfgFile string) {
|
|||||||
fmt.Printf("Enabled: %t\n", proxy.Enabled)
|
fmt.Printf("Enabled: %t\n", proxy.Enabled)
|
||||||
fmt.Printf("Server: %s\n\n", proxyServer)
|
fmt.Printf("Server: %s\n\n", proxyServer)
|
||||||
|
|
||||||
configs, _ := util.ReadConfigs(cfgFile)
|
configs, _ := util.ReadConfigs(cfgPath)
|
||||||
for _, config := range configs {
|
for _, config := range configs {
|
||||||
configCmd := config.Name
|
configCmd := config.Name
|
||||||
// Use command instead of name, if given
|
// Use command instead of name, if given
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
"github.com/Baipyrus/ProxySwitcher/util"
|
"github.com/Baipyrus/ProxySwitcher/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Set(cfgFile string) {
|
func Set(cfgPath string) {
|
||||||
stdin, closeFunc, _ := util.ReadyCmd()
|
stdin, closeFunc, _ := util.ReadyCmd()
|
||||||
|
|
||||||
proxy, _ := ReadSystemProxy()
|
proxy, _ := ReadSystemProxy()
|
||||||
@ -13,7 +13,7 @@ func Set(cfgFile string) {
|
|||||||
SetSystemProxy(true)
|
SetSystemProxy(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
configs, _ := util.ReadConfigs(cfgFile)
|
configs, _ := util.ReadConfigs(cfgPath)
|
||||||
for _, config := range configs {
|
for _, config := range configs {
|
||||||
configCmd := config.Name
|
configCmd := config.Name
|
||||||
// Use command instead of name, if given
|
// Use command instead of name, if given
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
"github.com/Baipyrus/ProxySwitcher/util"
|
"github.com/Baipyrus/ProxySwitcher/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Unset(cfgFile string) {
|
func Unset(cfgPath string) {
|
||||||
stdin, closeFunc, _ := util.ReadyCmd()
|
stdin, closeFunc, _ := util.ReadyCmd()
|
||||||
|
|
||||||
proxy, _ := ReadSystemProxy()
|
proxy, _ := ReadSystemProxy()
|
||||||
@ -13,7 +13,7 @@ func Unset(cfgFile string) {
|
|||||||
SetSystemProxy(false)
|
SetSystemProxy(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
configs, _ := util.ReadConfigs(cfgFile)
|
configs, _ := util.ReadConfigs(cfgPath)
|
||||||
for _, config := range configs {
|
for _, config := range configs {
|
||||||
configCmd := config.Name
|
configCmd := config.Name
|
||||||
// Use command instead of name, if given
|
// Use command instead of name, if given
|
||||||
|
Loading…
Reference in New Issue
Block a user