mirror of
https://github.com/Baipyrus/ProxySwitcher.git
synced 2024-12-26 12:41:45 +00:00
initialize save command
This commit is contained in:
parent
781baa2d45
commit
a0376269f8
39
cmd/save.go
Normal file
39
cmd/save.go
Normal file
@ -0,0 +1,39 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// saveCmd represents the save command
|
||||
var saveCmd = &cobra.Command{
|
||||
Use: "save",
|
||||
Short: "Save some new internet proxy settings",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Printf("Saving New 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
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(saveCmd)
|
||||
|
||||
// Here you will define your flags and configuration settings.
|
||||
|
||||
// Cobra supports Persistent Flags which will work for this command
|
||||
// and all subcommands, e.g.:
|
||||
// saveCmd.PersistentFlags().String("foo", "", "A help for foo")
|
||||
|
||||
// Cobra supports local flags which will only run when this command
|
||||
// is called directly, e.g.:
|
||||
// saveCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
||||
}
|
8
run.ps1
8
run.ps1
@ -35,6 +35,13 @@ $ctxDisable.Add_Click({
|
||||
Start-Process powershell.exe -ArgumentList '-Command', 'go run . unset'
|
||||
})
|
||||
|
||||
# Add "Save Proxy Setting" menu item
|
||||
$ctxSave = New-Object System.Windows.Forms.ToolStripMenuItem
|
||||
$ctxSave.Text = 'Save New Proxy'
|
||||
$ctxSave.Add_Click({
|
||||
Start-Process powershell.exe -ArgumentList '-Command', 'go run . save'
|
||||
})
|
||||
|
||||
# Add "Exit" menu item
|
||||
$ctxExit = New-Object System.Windows.Forms.ToolStripMenuItem
|
||||
$ctxExit.Text = 'Exit'
|
||||
@ -47,6 +54,7 @@ $ctxExit.Add_Click({
|
||||
$contextMenu.Items.Add($ctxProperties)
|
||||
$contextMenu.Items.Add($ctxEnable)
|
||||
$contextMenu.Items.Add($ctxDisable)
|
||||
$contextMenu.Items.Add($ctxSave)
|
||||
$contextMenu.Items.Add($ctxExit)
|
||||
|
||||
# Assign the context menu to the tray icon
|
||||
|
Loading…
Reference in New Issue
Block a user