diff --git a/internal/app/wwctl/container/build/root.go b/internal/app/wwctl/container/build/root.go index 71d01222..d02e651d 100644 --- a/internal/app/wwctl/container/build/root.go +++ b/internal/app/wwctl/container/build/root.go @@ -1,6 +1,9 @@ package build -import "github.com/spf13/cobra" +import ( + "github.com/hpcng/warewulf/internal/pkg/container" + "github.com/spf13/cobra" +) var ( baseCmd = &cobra.Command{ @@ -9,6 +12,13 @@ var ( Long: "This command will build a bootable VNFS image from an imported container image.", 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, _ := container.ListSources() + return list, cobra.ShellCompDirectiveNoFileComp + }, } BuildForce bool BuildAll bool diff --git a/internal/app/wwctl/container/delete/root.go b/internal/app/wwctl/container/delete/root.go index c753322a..fe0e5d23 100644 --- a/internal/app/wwctl/container/delete/root.go +++ b/internal/app/wwctl/container/delete/root.go @@ -1,6 +1,9 @@ package delete -import "github.com/spf13/cobra" +import ( + "github.com/hpcng/warewulf/internal/pkg/container" + "github.com/spf13/cobra" +) var ( baseCmd = &cobra.Command{ @@ -8,7 +11,13 @@ var ( Short: "Delete an imported container", Long: "This command will delete a container 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, _ := container.ListSources() + return list, cobra.ShellCompDirectiveNoFileComp + }, } ) diff --git a/internal/app/wwctl/container/exec/root.go b/internal/app/wwctl/container/exec/root.go index 561f8750..8e418541 100644 --- a/internal/app/wwctl/container/exec/root.go +++ b/internal/app/wwctl/container/exec/root.go @@ -2,6 +2,7 @@ package exec import ( "github.com/hpcng/warewulf/internal/app/wwctl/container/exec/child" + "github.com/hpcng/warewulf/internal/pkg/container" "github.com/spf13/cobra" ) @@ -12,8 +13,15 @@ var ( Long: "This command will allow you to run any command inside of a given\n" + "warewulf container. This is commonly used with an interactive shell such as /bin/bash\n" + "to run a virtual environment within the container.", - RunE: CobraRunE, - Args: cobra.MinimumNArgs(2), + RunE: CobraRunE, + Args: cobra.MinimumNArgs(2), + ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + if len(args) != 0 { + return nil, cobra.ShellCompDirectiveNoFileComp + } + list, _ := container.ListSources() + return list, cobra.ShellCompDirectiveNoFileComp + }, FParseErrWhitelist: cobra.FParseErrWhitelist{UnknownFlags: true}, } binds []string