Merge pull request #1729 from anderbubble/wwctl-hidden-commands

Hide internal `wwctl completion` and `wwctl genconfig` commands
This commit is contained in:
Christian Goll
2025-02-12 09:21:21 +01:00
committed by GitHub
6 changed files with 8 additions and 45 deletions

View File

@@ -12,6 +12,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Added support for comma-separated hostlist patterns. #1635
- Added default value for `warewulf.conf:dhcp.template`. #1725
### Changed
- Hide internal `wwctl completion` and `wwctl genconfig` commands. #1716
### Fixed
- Fixed detection of overlay files in `wwctl overlay list --long`.
@@ -23,6 +27,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Removed
- Removed partial support for regex searches in node and profile lists. #1635
- Remove redundant `wwctl genconfig completions` command. #1716
### Changed

View File

@@ -63,7 +63,7 @@ man_pages: wwctl $(wildcard docs/man/man5/*.5)
etc/bash_completion.d/wwctl: wwctl
mkdir -p etc/bash_completion.d/
./wwctl --emptyconf genconfig completions >etc/bash_completion.d/wwctl
./wwctl --emptyconf completion bash >etc/bash_completion.d/wwctl
.PHONY: lint
lint: $(config)

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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())

View File

@@ -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")