added wwctl genconf used to generate completions
Signed-off-by: Christian Goll <cgoll@suse.de>
This commit is contained in:
23
internal/app/wwctl/genconf/completions/main.go
Normal file
23
internal/app/wwctl/genconf/completions/main.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package completions
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
myArg := "bash"
|
||||
if len(args) == 1 {
|
||||
myArg = args[0]
|
||||
}
|
||||
switch myArg {
|
||||
case "zsh":
|
||||
cmd.GenZshCompletion(os.Stdout)
|
||||
case "fish":
|
||||
cmd.GenFishCompletion(os.Stdout, true)
|
||||
default:
|
||||
cmd.GenBashCompletion(os.Stdout)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
22
internal/app/wwctl/genconf/completions/root.go
Normal file
22
internal/app/wwctl/genconf/completions/root.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package completions
|
||||
|
||||
import "github.com/spf13/cobra"
|
||||
|
||||
var (
|
||||
baseCmd = &cobra.Command{
|
||||
Use: "completions",
|
||||
Short: "shell completion",
|
||||
Long: "This command generates the bash completions if no argument is given.",
|
||||
RunE: CobraRunE,
|
||||
Args: cobra.MaximumNArgs(1),
|
||||
Aliases: []string{"bash"},
|
||||
}
|
||||
Zsh bool
|
||||
)
|
||||
|
||||
func init() {
|
||||
}
|
||||
|
||||
func GetCommand() *cobra.Command {
|
||||
return baseCmd
|
||||
}
|
||||
26
internal/app/wwctl/genconf/root.go
Normal file
26
internal/app/wwctl/genconf/root.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package genconf
|
||||
|
||||
import (
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/genconf/completions"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var (
|
||||
baseCmd = &cobra.Command{
|
||||
Use: "genconfig",
|
||||
Short: "Generate various configurations",
|
||||
Long: "This command will allow you to generate different configurations like bash-completions.",
|
||||
Args: cobra.ExactArgs(0),
|
||||
Aliases: []string{"cnf"},
|
||||
}
|
||||
ListFull bool
|
||||
)
|
||||
|
||||
func init() {
|
||||
baseCmd.AddCommand(completions.GetCommand())
|
||||
}
|
||||
|
||||
// GetRootCommand returns the root cobra.Command for the application.
|
||||
func GetCommand() *cobra.Command {
|
||||
return baseCmd
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package wwctl
|
||||
import (
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/configure"
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/container"
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/genconf"
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/kernel"
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/node"
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/overlay"
|
||||
@@ -52,6 +53,7 @@ func init() {
|
||||
rootCmd.AddCommand(server.GetCommand())
|
||||
rootCmd.AddCommand(version.GetCommand())
|
||||
rootCmd.AddCommand(ssh.GetCommand())
|
||||
rootCmd.AddCommand(genconf.GetCommand())
|
||||
}
|
||||
|
||||
// GetRootCommand returns the root cobra.Command for the application.
|
||||
|
||||
Reference in New Issue
Block a user