generate man pages via sub command
Signed-off-by: Christian Goll <cgoll@suse.de>
This commit is contained in:
@@ -6,18 +6,18 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
func CobraRunE(cmd *cobra.Command, args []string) (err error) {
|
||||
myArg := "bash"
|
||||
if len(args) == 1 {
|
||||
myArg = args[0]
|
||||
}
|
||||
switch myArg {
|
||||
case "zsh":
|
||||
cmd.GenZshCompletion(os.Stdout)
|
||||
err = cmd.Parent().Parent().GenZshCompletion(os.Stdout)
|
||||
case "fish":
|
||||
cmd.GenFishCompletion(os.Stdout, true)
|
||||
err = cmd.Parent().Parent().GenFishCompletion(os.Stdout, true)
|
||||
default:
|
||||
cmd.GenBashCompletion(os.Stdout)
|
||||
err = cmd.Parent().Parent().GenBashCompletion(os.Stdout)
|
||||
}
|
||||
return nil
|
||||
return
|
||||
}
|
||||
|
||||
15
internal/app/wwctl/genconf/man/main.go
Normal file
15
internal/app/wwctl/genconf/man/main.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package man
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/cobra/doc"
|
||||
)
|
||||
|
||||
func CobraRunE(cmd *cobra.Command, args []string) (err error) {
|
||||
header := &doc.GenManHeader{
|
||||
Title: "WWCTL",
|
||||
Section: "1",
|
||||
}
|
||||
err = doc.GenManTree(cmd.Parent().Parent(), header, args[0])
|
||||
return
|
||||
}
|
||||
23
internal/app/wwctl/genconf/man/root.go
Normal file
23
internal/app/wwctl/genconf/man/root.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package man
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var (
|
||||
baseCmd = &cobra.Command{
|
||||
Use: "man",
|
||||
Short: "manpage generation",
|
||||
Long: "This command generates the man pages for all commands, needs target dir as argument",
|
||||
RunE: CobraRunE,
|
||||
Args: cobra.ExactArgs(1),
|
||||
Aliases: []string{"man_pages"},
|
||||
}
|
||||
)
|
||||
|
||||
func init() {
|
||||
}
|
||||
|
||||
func GetCommand() *cobra.Command {
|
||||
return baseCmd
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package genconf
|
||||
|
||||
import (
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/genconf/completions"
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/genconf/man"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
@@ -13,11 +14,13 @@ var (
|
||||
Args: cobra.ExactArgs(0),
|
||||
Aliases: []string{"cnf"},
|
||||
}
|
||||
ListFull bool
|
||||
ListFull bool
|
||||
WWctlRoot *cobra.Command
|
||||
)
|
||||
|
||||
func init() {
|
||||
baseCmd.AddCommand(completions.GetCommand())
|
||||
baseCmd.AddCommand(man.GetCommand())
|
||||
}
|
||||
|
||||
// GetRootCommand returns the root cobra.Command for the application.
|
||||
|
||||
Reference in New Issue
Block a user