Files
Tobias Ribizel 301082cdd7 add docstring for node patterns
Signed-off-by: Tobias Ribizel <mail@ribizel.de>
2025-07-06 16:36:45 +02:00

40 lines
1.4 KiB
Go

package list
import (
"github.com/spf13/cobra"
"github.com/warewulf/warewulf/internal/app/wwctl/completions"
"github.com/warewulf/warewulf/internal/pkg/hostlist"
)
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.\n" + hostlist.Docstring,
RunE: CobraRunE(&vars),
Aliases: []string{"ls"},
ValidArgsFunction: completions.Nodes,
Args: cobra.ArbitraryArgs,
}
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
}