Refactor to completions.Profiles

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
Jonathon Anderson
2025-02-05 18:56:16 -07:00
parent 60872bd42e
commit b05e384560
4 changed files with 16 additions and 28 deletions

View File

@@ -2,7 +2,7 @@ package list
import (
"github.com/spf13/cobra"
"github.com/warewulf/warewulf/internal/pkg/node"
"github.com/warewulf/warewulf/internal/app/wwctl/completions"
)
type variables struct {
@@ -21,13 +21,7 @@ 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
},
ValidArgsFunction: completions.Profiles,
}
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")