diff --git a/internal/app/wwctl/kernel/delete/root.go b/internal/app/wwctl/kernel/delete/root.go index 8295e4b5..4e714b46 100644 --- a/internal/app/wwctl/kernel/delete/root.go +++ b/internal/app/wwctl/kernel/delete/root.go @@ -1,6 +1,9 @@ package delete -import "github.com/spf13/cobra" +import ( + "github.com/hpcng/warewulf/internal/pkg/kernel" + "github.com/spf13/cobra" +) var ( baseCmd = &cobra.Command{ @@ -9,6 +12,13 @@ var ( Long: "This command will delete a kernel that has been imported into Warewulf.", RunE: CobraRunE, Args: cobra.MinimumNArgs(1), + ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + if len(args) != 0 { + return nil, cobra.ShellCompDirectiveNoFileComp + } + list, _ := kernel.ListKernels() + return list, cobra.ShellCompDirectiveNoFileComp + }, } ) diff --git a/internal/app/wwctl/kernel/imprt/root.go b/internal/app/wwctl/kernel/imprt/root.go index 5f97901c..eab31e79 100644 --- a/internal/app/wwctl/kernel/imprt/root.go +++ b/internal/app/wwctl/kernel/imprt/root.go @@ -1,6 +1,7 @@ package imprt import ( + "github.com/hpcng/warewulf/internal/pkg/container" "github.com/spf13/cobra" ) @@ -26,6 +27,10 @@ func init() { baseCmd.PersistentFlags().BoolVar(&SetDefault, "setdefault", false, "Set this kernel for the default profile") baseCmd.PersistentFlags().StringVarP(&OptRoot, "root", "r", "/", "Import kernel from root (chroot) directory") baseCmd.PersistentFlags().StringVarP(&OptContainer, "container", "C", "", "Import kernel from container") + baseCmd.RegisterFlagCompletionFunc("container", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + list, _ := container.ListSources() + return list, cobra.ShellCompDirectiveNoFileComp + }) } // GetRootCommand returns the root cobra.Command for the application.