Merge pull request #1702 from mslacken/completionProfiles
add completion for profile list
This commit is contained in:
@@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||||||
|
|
||||||
- Document defining kernel args that include commas. #1679
|
- Document defining kernel args that include commas. #1679
|
||||||
- Recommend installing ipmitool with Warewulf package. #970
|
- Recommend installing ipmitool with Warewulf package. #970
|
||||||
|
- Add completion for profile list. #1695
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
|||||||
@@ -52,3 +52,11 @@ func Images(cmd *cobra.Command, args []string, toComplete string) ([]string, cob
|
|||||||
sources, _ := image.ListSources()
|
sources, _ := image.ListSources()
|
||||||
return sources, cobra.ShellCompDirectiveNoFileComp
|
return sources, cobra.ShellCompDirectiveNoFileComp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Profiles(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||||
|
if len(args) != 0 {
|
||||||
|
return nil, cobra.ShellCompDirectiveNoFileComp
|
||||||
|
}
|
||||||
|
registry, _ := node.New()
|
||||||
|
return registry.ListAllProfiles(), cobra.ShellCompDirectiveNoFileComp
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package delete
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/warewulf/warewulf/internal/pkg/node"
|
"github.com/warewulf/warewulf/internal/app/wwctl/completions"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -14,13 +14,7 @@ var (
|
|||||||
Aliases: []string{"remove", "rm", "del"},
|
Aliases: []string{"remove", "rm", "del"},
|
||||||
RunE: CobraRunE,
|
RunE: CobraRunE,
|
||||||
Args: cobra.MinimumNArgs(1),
|
Args: cobra.MinimumNArgs(1),
|
||||||
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
ValidArgsFunction: completions.Profiles,
|
||||||
if len(args) != 0 {
|
|
||||||
return nil, cobra.ShellCompDirectiveNoFileComp
|
|
||||||
}
|
|
||||||
nodeDB, _ := node.New()
|
|
||||||
return nodeDB.ListAllProfiles(), cobra.ShellCompDirectiveNoFileComp
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
SetYes bool
|
SetYes bool
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
package list
|
package list
|
||||||
|
|
||||||
import "github.com/spf13/cobra"
|
import (
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
"github.com/warewulf/warewulf/internal/app/wwctl/completions"
|
||||||
|
)
|
||||||
|
|
||||||
type variables struct {
|
type variables struct {
|
||||||
showAll bool
|
showAll bool
|
||||||
@@ -18,6 +21,7 @@ func GetCommand() *cobra.Command {
|
|||||||
Long: "This command will display configurations for PROFILE.",
|
Long: "This command will display configurations for PROFILE.",
|
||||||
RunE: CobraRunE(&vars),
|
RunE: CobraRunE(&vars),
|
||||||
Aliases: []string{"ls"},
|
Aliases: []string{"ls"},
|
||||||
|
ValidArgsFunction: completions.Profiles,
|
||||||
}
|
}
|
||||||
baseCmd.PersistentFlags().BoolVarP(&vars.showAll, "all", "a", false, "Show all profile configurations")
|
baseCmd.PersistentFlags().BoolVarP(&vars.showAll, "all", "a", false, "Show all profile configurations")
|
||||||
baseCmd.PersistentFlags().BoolVarP(&vars.showYaml, "yaml", "y", false, "Show profile configurations via yaml format")
|
baseCmd.PersistentFlags().BoolVarP(&vars.showYaml, "yaml", "y", false, "Show profile configurations via yaml format")
|
||||||
|
|||||||
@@ -36,18 +36,10 @@ func GetCommand() *cobra.Command {
|
|||||||
Short: "Configure node profile properties",
|
Short: "Configure node profile properties",
|
||||||
Long: "This command sets configuration properties for the node PROFILE(s).\n\n" +
|
Long: "This command sets configuration properties for the node PROFILE(s).\n\n" +
|
||||||
"Note: use the string 'UNSET' to remove a configuration",
|
"Note: use the string 'UNSET' to remove a configuration",
|
||||||
Aliases: []string{"modify"},
|
Aliases: []string{"modify"},
|
||||||
Args: cobra.MinimumNArgs(0),
|
Args: cobra.MinimumNArgs(0),
|
||||||
RunE: CobraRunE(&vars),
|
RunE: CobraRunE(&vars),
|
||||||
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
ValidArgsFunction: completions.Profiles,
|
||||||
if len(args) != 0 {
|
|
||||||
return nil, cobra.ShellCompDirectiveNoFileComp
|
|
||||||
}
|
|
||||||
|
|
||||||
nodeDB, _ := node.New()
|
|
||||||
profiles := nodeDB.ListAllProfiles()
|
|
||||||
return profiles, cobra.ShellCompDirectiveNoFileComp
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
vars.profileConf.CreateFlags(baseCmd)
|
vars.profileConf.CreateFlags(baseCmd)
|
||||||
vars.profileDel.CreateDelFlags(baseCmd)
|
vars.profileDel.CreateDelFlags(baseCmd)
|
||||||
|
|||||||
Reference in New Issue
Block a user