From 6bae350f7e22dc8f69d8586102deee41700a83b4 Mon Sep 17 00:00:00 2001 From: Baipyrus Date: Sat, 31 Aug 2024 18:01:58 +0200 Subject: [PATCH] preparing proxy set/unset commands --- cmd/set.go | 18 ++---------------- cmd/unset.go | 14 ++------------ proxy/set.go | 4 ++++ proxy/unset.go | 3 +++ 4 files changed, 11 insertions(+), 28 deletions(-) create mode 100644 proxy/set.go create mode 100644 proxy/unset.go diff --git a/cmd/set.go b/cmd/set.go index 27b1324..a919588 100644 --- a/cmd/set.go +++ b/cmd/set.go @@ -1,13 +1,7 @@ package cmd import ( - "encoding/json" - "fmt" - "os" - "os/signal" - "syscall" - - "github.com/Baipyrus/ProxySwitcher/util" + "github.com/Baipyrus/ProxySwitcher/proxy" "github.com/spf13/cobra" ) @@ -16,15 +10,7 @@ var setCmd = &cobra.Command{ Use: "set", Short: "Enable the current internet proxy settings", Run: func(cmd *cobra.Command, args []string) { - config, _ := util.ReadConfigs() - 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 + proxy.Set() }, } diff --git a/cmd/unset.go b/cmd/unset.go index 5edc92a..65a9917 100644 --- a/cmd/unset.go +++ b/cmd/unset.go @@ -1,11 +1,7 @@ package cmd import ( - "fmt" - "os" - "os/signal" - "syscall" - + "github.com/Baipyrus/ProxySwitcher/proxy" "github.com/spf13/cobra" ) @@ -14,13 +10,7 @@ var unsetCmd = &cobra.Command{ Use: "unset", Short: "Disable the current internet proxy settings", Run: func(cmd *cobra.Command, args []string) { - fmt.Printf("Unsetting Proxy Settings...\n") - - // 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 + proxy.Unset() }, } diff --git a/proxy/set.go b/proxy/set.go new file mode 100644 index 0000000..255ae78 --- /dev/null +++ b/proxy/set.go @@ -0,0 +1,4 @@ +package proxy + +func Set() { +} diff --git a/proxy/unset.go b/proxy/unset.go new file mode 100644 index 0000000..f904a88 --- /dev/null +++ b/proxy/unset.go @@ -0,0 +1,3 @@ +package proxy + +}