From 4a519f3d01faadc1666bf8609fa9a21b384330bd Mon Sep 17 00:00:00 2001 From: Kadin Sayani Date: Tue, 7 Jan 2025 15:53:25 -0700 Subject: [PATCH] lxc/completion: Add completions for `lxc image alias list|delete|rename` Signed-off-by: Kadin Sayani --- lxc/image_alias.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lxc/image_alias.go b/lxc/image_alias.go index b0b0deeee57c..1a0d2a4a3a26 100644 --- a/lxc/image_alias.go +++ b/lxc/image_alias.go @@ -126,6 +126,14 @@ func (c *cmdImageAliasDelete) command() *cobra.Command { cmd.RunE = c.run + cmd.ValidArgsFunction = func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + if len(args) > 0 { + return nil, cobra.ShellCompDirectiveNoFileComp + } + + return c.global.cmpImages(toComplete) + } + return cmd } @@ -175,6 +183,14 @@ Filters may be part of the image hash or part of the image alias name. cmd.RunE = c.run + cmd.ValidArgsFunction = func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + if len(args) > 0 { + return nil, cobra.ShellCompDirectiveNoFileComp + } + + return c.global.cmpRemotes(toComplete, true) + } + return cmd } @@ -274,6 +290,14 @@ func (c *cmdImageAliasRename) command() *cobra.Command { cmd.RunE = c.run + cmd.ValidArgsFunction = func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + if len(args) > 0 { + return nil, cobra.ShellCompDirectiveNoFileComp + } + + return c.global.cmpImages(toComplete) + } + return cmd }