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

View File

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

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
}