mirror of
https://github.com/Baipyrus/ProxySwitcher.git
synced 2024-12-26 12:41:45 +00:00
preparing proxy set/unset commands
This commit is contained in:
parent
43123b3ffc
commit
6bae350f7e
18
cmd/set.go
18
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()
|
||||
},
|
||||
}
|
||||
|
||||
|
14
cmd/unset.go
14
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()
|
||||
},
|
||||
}
|
||||
|
||||
|
4
proxy/set.go
Normal file
4
proxy/set.go
Normal file
@ -0,0 +1,4 @@
|
||||
package proxy
|
||||
|
||||
func Set() {
|
||||
}
|
3
proxy/unset.go
Normal file
3
proxy/unset.go
Normal file
@ -0,0 +1,3 @@
|
||||
package proxy
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user