preparing proxy set/unset commands

This commit is contained in:
Baipyrus 2024-08-31 18:01:58 +02:00
parent 43123b3ffc
commit 6bae350f7e
4 changed files with 11 additions and 28 deletions

View File

@ -1,13 +1,7 @@
package cmd package cmd
import ( import (
"encoding/json" "github.com/Baipyrus/ProxySwitcher/proxy"
"fmt"
"os"
"os/signal"
"syscall"
"github.com/Baipyrus/ProxySwitcher/util"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
@ -16,15 +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) {
config, _ := util.ReadConfigs() proxy.Set()
data, _ := json.Marshal(config)
fmt.Printf("%s\n\n", string(data))
// Block process until interrupted
done := make(chan os.Signal, 1)
signal.Notify(done, syscall.SIGINT, syscall.SIGTERM)
fmt.Println("Blocking, press ctrl+c to continue...")
<-done
}, },
} }

View File

@ -1,11 +1,7 @@
package cmd package cmd
import ( import (
"fmt" "github.com/Baipyrus/ProxySwitcher/proxy"
"os"
"os/signal"
"syscall"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
@ -14,13 +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) {
fmt.Printf("Unsetting Proxy Settings...\n") proxy.Unset()
// Block process until interrupted
done := make(chan os.Signal, 1)
signal.Notify(done, syscall.SIGINT, syscall.SIGTERM)
fmt.Println("Blocking, press ctrl+c to continue...")
<-done
}, },
} }

4
proxy/set.go Normal file
View File

@ -0,0 +1,4 @@
package proxy
func Set() {
}

3
proxy/unset.go Normal file
View File

@ -0,0 +1,3 @@
package proxy
}