Merge pull request #1729 from anderbubble/wwctl-hidden-commands
Hide internal `wwctl completion` and `wwctl genconfig` commands
This commit is contained in:
@@ -1,23 +0,0 @@
|
||||
package completions
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func CobraRunE(cmd *cobra.Command, args []string) (err error) {
|
||||
myArg := "bash"
|
||||
if len(args) == 1 {
|
||||
myArg = args[0]
|
||||
}
|
||||
switch myArg {
|
||||
case "zsh":
|
||||
err = cmd.Parent().Parent().GenZshCompletion(os.Stdout)
|
||||
case "fish":
|
||||
err = cmd.Parent().Parent().GenFishCompletion(os.Stdout, true)
|
||||
default:
|
||||
err = cmd.Parent().Parent().GenBashCompletion(os.Stdout)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
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 GetCommand() *cobra.Command {
|
||||
return baseCmd
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package genconf
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/warewulf/warewulf/internal/app/wwctl/genconf/completions"
|
||||
"github.com/warewulf/warewulf/internal/app/wwctl/genconf/man"
|
||||
"github.com/warewulf/warewulf/internal/app/wwctl/genconf/reference"
|
||||
"github.com/warewulf/warewulf/internal/app/wwctl/genconf/warewulfconf"
|
||||
@@ -18,13 +17,13 @@ var (
|
||||
Args: cobra.NoArgs,
|
||||
Aliases: []string{"cnf"},
|
||||
ValidArgsFunction: cobraCompletions.None,
|
||||
Hidden: true,
|
||||
}
|
||||
ListFull bool
|
||||
WWctlRoot *cobra.Command
|
||||
)
|
||||
|
||||
func init() {
|
||||
baseCmd.AddCommand(completions.GetCommand())
|
||||
baseCmd.AddCommand(man.GetCommand())
|
||||
baseCmd.AddCommand(reference.GetCommand())
|
||||
baseCmd.AddCommand(warewulfconf.GetCommand())
|
||||
|
||||
@@ -39,6 +39,7 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
rootCmd.CompletionOptions.HiddenDefaultCmd = true
|
||||
rootCmd.PersistentFlags().BoolVarP(&verboseArg, "verbose", "v", false, "Run with increased verbosity.")
|
||||
rootCmd.PersistentFlags().BoolVarP(&DebugFlag, "debug", "d", false, "Run with debugging messages enabled.")
|
||||
rootCmd.PersistentFlags().IntVar(&LogLevel, "loglevel", wwlog.INFO, "Set log level to given string")
|
||||
|
||||
Reference in New Issue
Block a user