From c9bc3b8e2dbab46e8ea638d4ccf994e5de6b1c27 Mon Sep 17 00:00:00 2001 From: Jack Thomasson <4302889+jkt628@users.noreply.github.com> Date: Sun, 26 Jan 2025 11:37:42 -0500 Subject: [PATCH 1/3] process non-String flags --- cmd/network_update.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/network_update.go b/cmd/network_update.go index e573bfd..f761044 100644 --- a/cmd/network_update.go +++ b/cmd/network_update.go @@ -131,7 +131,7 @@ func parseNetworkArgs(cmd *cobra.Command, args []NetworkArg) map[string]interfac val, err = cmd.Flags().GetStringArray(arg.Arg) changed = len(val.([]string)) > 0 } else { - val, err = cmd.Flags().GetString(arg.Arg) + val = cmd.Flags().Lookup(arg.Arg).Value.String() changed = val.(string) != "" } From dda59df75b6aec5172ccbfa81ea4e821810580a2 Mon Sep 17 00:00:00 2001 From: Jack Thomasson <4302889+jkt628@users.noreply.github.com> Date: Sun, 26 Jan 2025 11:39:12 -0500 Subject: [PATCH 2/3] add IP method "shared" --- cmd/network.go | 2 +- cmd/network_update.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/network.go b/cmd/network.go index 8848b09..d8dfb36 100644 --- a/cmd/network.go +++ b/cmd/network.go @@ -25,7 +25,7 @@ func init() { } func ipMethodCompletions(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - return []string{"static", "auto", "disabled"}, cobra.ShellCompDirectiveNoFileComp + return []string{"static", "auto", "disabled", "shared"}, cobra.ShellCompDirectiveNoFileComp } func networkInterfaceCompletions(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { diff --git a/cmd/network_update.go b/cmd/network_update.go index f761044..d2049b9 100644 --- a/cmd/network_update.go +++ b/cmd/network_update.go @@ -75,7 +75,7 @@ func init() { networkUpdateCmd.Flags().StringArray("ipv4-address", []string{}, "IPv4 address for the interface in the 192.168.1.5/24") networkUpdateCmd.Flags().String("ipv4-gateway", "", "The IPv4 gateway the interface should use") - networkUpdateCmd.Flags().String("ipv4-method", "", "Method on IPv4: static|auto|disabled") + networkUpdateCmd.Flags().String("ipv4-method", "", "Method on IPv4: static|auto|disabled|shared") networkUpdateCmd.Flags().StringArray("ipv4-nameserver", []string{}, "IPv4 address of upstream DNS servers. Use multiple times for multiple servers.") networkUpdateCmd.Flags().StringArray("ipv6-address", []string{}, "IPv6 address for the interface in the 2001:0db8:85a3:0000:0000:8a2e:0370:7334/64") From b7a0326abe241abbe561229fa6ffb647de209e98 Mon Sep 17 00:00:00 2001 From: Jack Thomasson <4302889+jkt628@users.noreply.github.com> Date: Sun, 26 Jan 2025 11:40:07 -0500 Subject: [PATCH 3/3] add flags "wifi-band" and "wifi-channel" --- cmd/network_update.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmd/network_update.go b/cmd/network_update.go index d2049b9..1dd671e 100644 --- a/cmd/network_update.go +++ b/cmd/network_update.go @@ -87,6 +87,8 @@ func init() { networkUpdateCmd.Flags().String("wifi-ssid", "", "SSID for wifi connection") networkUpdateCmd.Flags().String("wifi-auth", "", "Used authentication: open, wep, wpa-psk") networkUpdateCmd.Flags().String("wifi-psk", "", "Shared authentication key for wep or wpa") + networkUpdateCmd.Flags().String("wifi-band", "", "Wifi band required for mode 'ap': a for 5GHz, bg for 2.4GHz") + networkUpdateCmd.Flags().Int("wifi-channel", 0, "Wifi channel required for mode 'ap'") networkUpdateCmd.Flags().BoolP("disabled", "e", false, "Disable interface") @@ -108,6 +110,10 @@ func init() { return []string{"open", "wep", "wpa-psk"}, cobra.ShellCompDirectiveNoFileComp }) networkUpdateCmd.RegisterFlagCompletionFunc("wifi-psk", cobra.NoFileCompletions) + networkUpdateCmd.RegisterFlagCompletionFunc("wifi-band", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + return []string{"a", "bg"}, cobra.ShellCompDirectiveNoFileComp + }) + networkUpdateCmd.RegisterFlagCompletionFunc("wifi-channel", cobra.NoFileCompletions) networkUpdateCmd.RegisterFlagCompletionFunc("disabled", boolCompletions) @@ -162,6 +168,8 @@ func helperWifiConfig(cmd *cobra.Command, options map[string]interface{}) { {Arg: "wifi-ssid", ApiKey: "ssid"}, {Arg: "wifi-auth", ApiKey: "auth"}, {Arg: "wifi-psk", ApiKey: "psk"}, + {Arg: "wifi-band", ApiKey: "band"}, + {Arg: "wifi-channel", ApiKey: "channel"}, } wifiConfig := parseNetworkArgs(cmd, args)