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
|
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
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
14
cmd/unset.go
14
cmd/unset.go
@ -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
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