wwctl node args and completions

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
Jonathon Anderson
2025-02-08 16:57:49 -07:00
parent 5494424c09
commit 08a8eb430c
16 changed files with 213 additions and 246 deletions

View File

@@ -2,7 +2,7 @@ package sensors
import (
"github.com/spf13/cobra"
"github.com/warewulf/warewulf/internal/pkg/node"
"github.com/warewulf/warewulf/internal/app/wwctl/completions"
)
type variables struct {
@@ -21,19 +21,7 @@ func GetCommand() *cobra.Command {
Long: "Show IPMI sensor information for nodes matching PATTERN.",
Args: cobra.MinimumNArgs(1),
RunE: CobraRunE(&vars),
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
if len(args) != 0 {
return nil, cobra.ShellCompDirectiveNoFileComp
}
nodeDB, _ := node.New()
nodes, _ := nodeDB.FindAllNodes()
var node_names []string
for _, node := range nodes {
node_names = append(node_names, node.Id())
}
return node_names, cobra.ShellCompDirectiveNoFileComp
},
ValidArgsFunction: completions.Nodes(0), // no limit
}
powerCmd.PersistentFlags().BoolVarP(&vars.Full, "full", "F", false, "show detailed output.")
powerCmd.PersistentFlags().BoolVarP(&vars.Showcmd, "show", "s", false, "only show command which will be executed")