Files
warewulf/internal/app/wwctl/node/list/root.go
Jonathon Anderson 3b963ee5a6 Simplify node, profile, and image completions
Signed-off-by: Jonathon Anderson <janderson@ciq.com>
2025-02-09 16:38:27 -07:00

38 lines
1.3 KiB
Go

package list
import (
"github.com/spf13/cobra"
"github.com/warewulf/warewulf/internal/app/wwctl/completions"
)
type variables struct {
showNet bool
showIpmi bool
showAll bool
showLong bool
showYaml bool
showJson bool
}
func GetCommand() *cobra.Command {
vars := variables{}
baseCmd := &cobra.Command{
DisableFlagsInUseLine: true,
Use: "list [OPTIONS] [PATTERN]",
Short: "List nodes",
Long: "This command lists all configured nodes. Optionally, it will list only\n" +
"nodes matching a PATTERN.",
RunE: CobraRunE(&vars),
Aliases: []string{"ls"},
ValidArgsFunction: completions.Nodes,
}
baseCmd.PersistentFlags().BoolVarP(&vars.showNet, "net", "n", false, "Show node network configurations")
baseCmd.PersistentFlags().BoolVarP(&vars.showIpmi, "ipmi", "i", false, "Show node IPMI configurations")
baseCmd.PersistentFlags().BoolVarP(&vars.showAll, "all", "a", false, "Show all node configurations")
baseCmd.PersistentFlags().BoolVarP(&vars.showLong, "long", "l", false, "Show long or wide format")
baseCmd.PersistentFlags().BoolVarP(&vars.showYaml, "yaml", "y", false, "Show yaml format")
baseCmd.PersistentFlags().BoolVarP(&vars.showJson, "json", "j", false, "Show json format")
return baseCmd
}