mirror of
https://github.com/Baipyrus/ProxySwitcher.git
synced 2024-12-25 12:11:46 +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",
|
||||
Short: "Output all parsed configurations for debugging",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
proxy.Debug(cfgFile)
|
||||
proxy.Debug(cfgPath)
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
@ -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)
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user