diff --git a/CHANGELOG.md b/CHANGELOG.md index 93b2e98b..88cac6d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Document defining kernel args that include commas. #1679 - Recommend installing ipmitool with Warewulf package. #970 +- Add completion for profile list. #1695 ### Changed diff --git a/internal/app/wwctl/profile/list/root.go b/internal/app/wwctl/profile/list/root.go index e0317b28..ff63b599 100644 --- a/internal/app/wwctl/profile/list/root.go +++ b/internal/app/wwctl/profile/list/root.go @@ -1,6 +1,9 @@ package list -import "github.com/spf13/cobra" +import ( + "github.com/spf13/cobra" + "github.com/warewulf/warewulf/internal/pkg/node" +) type variables struct { showAll bool @@ -18,6 +21,13 @@ func GetCommand() *cobra.Command { Long: "This command will display configurations for PROFILE.", RunE: CobraRunE(&vars), Aliases: []string{"ls"}, + ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + if len(args) != 0 { + return nil, cobra.ShellCompDirectiveNoFileComp + } + nodeDB, _ := node.New() + return nodeDB.ListAllProfiles(), cobra.ShellCompDirectiveNoFileComp + }, } baseCmd.PersistentFlags().BoolVarP(&vars.showAll, "all", "a", false, "Show all profile configurations") baseCmd.PersistentFlags().BoolVarP(&vars.showYaml, "yaml", "y", false, "Show profile configurations via yaml format")