diff --git a/CHANGELOG.md b/CHANGELOG.md index dfe0d8cb..f7b850f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Added - Show more information during `wwctl container ` about when and if the container image will be rebuilt. #1302 +- Command-line completion for `wwctl overlay `. #1298 ### Fixed diff --git a/internal/app/wwctl/overlay/chmod/root.go b/internal/app/wwctl/overlay/chmod/root.go index 6be9be0d..13d7e715 100644 --- a/internal/app/wwctl/overlay/chmod/root.go +++ b/internal/app/wwctl/overlay/chmod/root.go @@ -15,11 +15,16 @@ var ( RunE: CobraRunE, Args: cobra.ExactArgs(3), ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - if len(args) != 0 { - return nil, cobra.ShellCompDirectiveNoFileComp + if len(args) == 0 { + list, _ := overlay.FindOverlays() + return list, cobra.ShellCompDirectiveNoFileComp + } else if len(args) == 1 { + ret, err := overlay.OverlayGetFiles(args[0]) + if err == nil { + return ret, cobra.ShellCompDirectiveNoFileComp + } } - list, _ := overlay.FindOverlays() - return list, cobra.ShellCompDirectiveNoFileComp + return []string{""}, cobra.ShellCompDirectiveNoFileComp }, } ) diff --git a/internal/app/wwctl/overlay/chown/root.go b/internal/app/wwctl/overlay/chown/root.go index 45c51772..7c2604b1 100644 --- a/internal/app/wwctl/overlay/chown/root.go +++ b/internal/app/wwctl/overlay/chown/root.go @@ -14,11 +14,16 @@ var ( RunE: CobraRunE, Args: cobra.RangeArgs(3, 4), ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - if len(args) != 0 { - return nil, cobra.ShellCompDirectiveNoFileComp + if len(args) == 0 { + list, _ := overlay.FindOverlays() + return list, cobra.ShellCompDirectiveNoFileComp + } else if len(args) == 1 { + ret, err := overlay.OverlayGetFiles(args[0]) + if err == nil { + return ret, cobra.ShellCompDirectiveNoFileComp + } } - list, _ := overlay.FindOverlays() - return list, cobra.ShellCompDirectiveNoFileComp + return []string{""}, cobra.ShellCompDirectiveNoFileComp }, } ) diff --git a/internal/app/wwctl/overlay/delete/root.go b/internal/app/wwctl/overlay/delete/root.go index 1de69417..289cea96 100644 --- a/internal/app/wwctl/overlay/delete/root.go +++ b/internal/app/wwctl/overlay/delete/root.go @@ -15,11 +15,16 @@ var ( Args: cobra.RangeArgs(1, 2), Aliases: []string{"rm", "remove", "del"}, ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - if len(args) != 0 { - return nil, cobra.ShellCompDirectiveNoFileComp + if len(args) == 0 { + list, _ := overlay.FindOverlays() + return list, cobra.ShellCompDirectiveNoFileComp + } else if len(args) == 1 { + ret, err := overlay.OverlayGetFiles(args[0]) + if err == nil { + return ret, cobra.ShellCompDirectiveNoFileComp + } } - list, _ := overlay.FindOverlays() - return list, cobra.ShellCompDirectiveNoFileComp + return []string{""}, cobra.ShellCompDirectiveNoFileComp }, } Force bool diff --git a/internal/app/wwctl/overlay/edit/root.go b/internal/app/wwctl/overlay/edit/root.go index 7e07f741..f2cefdef 100644 --- a/internal/app/wwctl/overlay/edit/root.go +++ b/internal/app/wwctl/overlay/edit/root.go @@ -14,11 +14,16 @@ var ( RunE: CobraRunE, Args: cobra.ExactArgs(2), ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - if len(args) != 0 { - return nil, cobra.ShellCompDirectiveNoFileComp + if len(args) == 0 { + list, _ := overlay.FindOverlays() + return list, cobra.ShellCompDirectiveNoFileComp + } else if len(args) == 1 { + ret, err := overlay.OverlayGetFiles(args[0]) + if err == nil { + return ret, cobra.ShellCompDirectiveNoFileComp + } } - list, _ := overlay.FindOverlays() - return list, cobra.ShellCompDirectiveNoFileComp + return []string{""}, cobra.ShellCompDirectiveNoFileComp }, } CreateDirs bool