From dd2d915b7ebc0b9c0bfa9367a1e4b7ecbfdc2346 Mon Sep 17 00:00:00 2001 From: Kadin Sayani Date: Fri, 20 Dec 2024 14:43:25 -0700 Subject: [PATCH] lxc/completion: Add network completions to `lxc network forward create` Signed-off-by: Kadin Sayani --- lxc/network_forward.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lxc/network_forward.go b/lxc/network_forward.go index d8c47284b970..ba093c6f479f 100644 --- a/lxc/network_forward.go +++ b/lxc/network_forward.go @@ -264,6 +264,14 @@ lxc network forward create n1 127.0.0.1 < config.yaml cmd.Flags().StringVar(&c.networkForward.flagTarget, "target", "", i18n.G("Cluster member name")+"``") cmd.Flags().StringVar(&c.flagAllocate, "allocate", "", i18n.G("Auto-allocate an IPv4 or IPv6 listen address. One of 'ipv4', 'ipv6'.")+"``") + cmd.ValidArgsFunction = func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + if len(args) == 0 { + return c.global.cmpNetworks(toComplete) + } + + return nil, cobra.ShellCompDirectiveNoFileComp + } + return cmd }