wwctl profile args and completions

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
Jonathon Anderson
2025-02-09 13:42:16 -07:00
parent 32b9696b71
commit 3fbc2fc75c
6 changed files with 20 additions and 61 deletions

View File

@@ -2,7 +2,7 @@ package edit
import (
"github.com/spf13/cobra"
"github.com/warewulf/warewulf/internal/pkg/node"
"github.com/warewulf/warewulf/internal/app/wwctl/completions"
)
var (
@@ -12,18 +12,7 @@ var (
Short: "Edit node(s) with editor",
Long: "This command opens an editor for the given profiles.",
RunE: CobraRunE,
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
if len(args) != 0 {
return nil, cobra.ShellCompDirectiveNoFileComp
}
nodeDB, _ := node.New()
profiles, _ := nodeDB.FindAllProfiles()
var p_names []string
for _, profile := range profiles {
p_names = append(p_names, profile.Id())
}
return p_names, cobra.ShellCompDirectiveNoFileComp
},
ValidArgsFunction: completions.Profiles(0),
}
NoHeader bool
)