wwctl profile args and completions
Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
@@ -1,14 +1,10 @@
|
||||
package set
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/warewulf/warewulf/internal/app/wwctl/completions"
|
||||
"github.com/warewulf/warewulf/internal/app/wwctl/flags"
|
||||
"github.com/warewulf/warewulf/internal/pkg/image"
|
||||
"github.com/warewulf/warewulf/internal/pkg/node"
|
||||
"github.com/warewulf/warewulf/internal/pkg/overlay"
|
||||
)
|
||||
|
||||
type variables struct {
|
||||
@@ -37,9 +33,8 @@ func GetCommand() *cobra.Command {
|
||||
Long: "This command sets configuration properties for the node PROFILE(s).\n\n" +
|
||||
"Note: use the string 'UNSET' to remove a configuration",
|
||||
Aliases: []string{"modify"},
|
||||
Args: cobra.MinimumNArgs(0),
|
||||
RunE: CobraRunE(&vars),
|
||||
ValidArgsFunction: completions.Profiles,
|
||||
ValidArgsFunction: completions.Profiles(0), // no limit
|
||||
}
|
||||
vars.profileConf.CreateFlags(baseCmd)
|
||||
vars.profileDel.CreateDelFlags(baseCmd)
|
||||
@@ -47,26 +42,17 @@ func GetCommand() *cobra.Command {
|
||||
flags.AddContainer(baseCmd, &(vars.profileConf.ImageName))
|
||||
baseCmd.PersistentFlags().BoolVarP(&vars.setYes, "yes", "y", false, "Set 'yes' to all questions asked")
|
||||
// register the command line completions
|
||||
if err := baseCmd.RegisterFlagCompletionFunc("image", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
list, _ := image.ListSources()
|
||||
return list, cobra.ShellCompDirectiveNoFileComp
|
||||
}); err != nil {
|
||||
log.Println(err)
|
||||
if err := baseCmd.RegisterFlagCompletionFunc("image", completions.Images(0)); err != nil { // no limit
|
||||
panic(err)
|
||||
}
|
||||
if err := baseCmd.RegisterFlagCompletionFunc("kernelversion", completions.ProfileKernelVersion); err != nil {
|
||||
log.Println(err)
|
||||
panic(err)
|
||||
}
|
||||
if err := baseCmd.RegisterFlagCompletionFunc("runtime", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
list := overlay.FindOverlays()
|
||||
return list, cobra.ShellCompDirectiveNoFileComp
|
||||
}); err != nil {
|
||||
log.Println(err)
|
||||
if err := baseCmd.RegisterFlagCompletionFunc("runtime", completions.Overlays); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := baseCmd.RegisterFlagCompletionFunc("wwinit", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
list := overlay.FindOverlays()
|
||||
return list, cobra.ShellCompDirectiveNoFileComp
|
||||
}); err != nil {
|
||||
log.Println(err)
|
||||
if err := baseCmd.RegisterFlagCompletionFunc("wwinit", completions.Overlays); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return baseCmd
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user