generate man pages via sub command
Signed-off-by: Christian Goll <cgoll@suse.de>
This commit is contained in:
16
Makefile
16
Makefile
@@ -196,6 +196,7 @@ files: all
|
|||||||
chmod 644 $(DESTDIR)$(WWOVERLAYDIR)/wwinit/warewulf/config.ww
|
chmod 644 $(DESTDIR)$(WWOVERLAYDIR)/wwinit/warewulf/config.ww
|
||||||
chmod 750 $(DESTDIR)$(WWOVERLAYDIR)/host
|
chmod 750 $(DESTDIR)$(WWOVERLAYDIR)/host
|
||||||
install -m 0755 wwctl $(DESTDIR)$(BINDIR)
|
install -m 0755 wwctl $(DESTDIR)$(BINDIR)
|
||||||
|
install -m 0755 wwclient $(DESTDIR)$(WWOVERLAYDIR)/wwinit/$(WWCLIENTDIR)/wwclient
|
||||||
install -m 0755 wwapic $(DESTDIR)$(BINDIR)
|
install -m 0755 wwapic $(DESTDIR)$(BINDIR)
|
||||||
install -m 0755 wwapid $(DESTDIR)$(BINDIR)
|
install -m 0755 wwapid $(DESTDIR)$(BINDIR)
|
||||||
install -m 0755 wwapird $(DESTDIR)$(BINDIR)
|
install -m 0755 wwapird $(DESTDIR)$(BINDIR)
|
||||||
@@ -224,17 +225,9 @@ wwclient: $(WWCLIENT_DEPS)
|
|||||||
@ cd cmd/wwclient; CGO_ENABLED=0 GOOS=linux go build -mod vendor -a -ldflags "-extldflags -static \
|
@ cd cmd/wwclient; CGO_ENABLED=0 GOOS=linux go build -mod vendor -a -ldflags "-extldflags -static \
|
||||||
-X 'github.com/hpcng/warewulf/internal/pkg/warewulfconf.ConfigFile=/etc/warewulf/warewulf.conf'" -o ../../wwclient
|
-X 'github.com/hpcng/warewulf/internal/pkg/warewulfconf.ConfigFile=/etc/warewulf/warewulf.conf'" -o ../../wwclient
|
||||||
|
|
||||||
install_wwclient: wwclient
|
man_pages: wwctl
|
||||||
install -m 0755 wwclient $(DESTDIR)$(WWOVERLAYDIR)/wwinit/$(WWCLIENTDIR)/wwclient
|
|
||||||
|
|
||||||
man_page:
|
|
||||||
cd cmd/man_page && go build -ldflags="-X 'github.com/hpcng/warewulf/internal/pkg/warewulfconf.ConfigFile=./etc/warewulf.conf'\
|
|
||||||
-X 'github.com/hpcng/warewulf/internal/pkg/node.ConfigFile=./etc/nodes.conf'"\
|
|
||||||
-mod vendor -tags "$(WW_GO_BUILD_TAGS)" -o ../../man_page
|
|
||||||
|
|
||||||
man_pages: man_page
|
|
||||||
install -d man_pages
|
install -d man_pages
|
||||||
./man_page ./man_pages
|
./wwctl genconfig man man_pages
|
||||||
cp docs/man/man5/*.5 ./man_pages/
|
cp docs/man/man5/*.5 ./man_pages/
|
||||||
cd man_pages; for i in wwctl*1 *.5; do echo "Compressing manpage: $$i"; gzip --force $$i; done
|
cd man_pages; for i in wwctl*1 *.5; do echo "Compressing manpage: $$i"; gzip --force $$i; done
|
||||||
|
|
||||||
@@ -295,7 +288,6 @@ contclean:
|
|||||||
rm -f wwctl
|
rm -f wwctl
|
||||||
rm -rf .dist
|
rm -rf .dist
|
||||||
rm -f $(WAREWULF)-$(VERSION).tar.gz
|
rm -f $(WAREWULF)-$(VERSION).tar.gz
|
||||||
rm -f man_page
|
|
||||||
rm -rf man_pages
|
rm -rf man_pages
|
||||||
rm -f warewulf.spec
|
rm -f warewulf.spec
|
||||||
rm -f config
|
rm -f config
|
||||||
@@ -309,6 +301,6 @@ contclean:
|
|||||||
clean: contclean
|
clean: contclean
|
||||||
rm -rf vendor
|
rm -rf vendor
|
||||||
|
|
||||||
install: files install_wwclient
|
install: files
|
||||||
|
|
||||||
debinstall: files debfiles
|
debinstall: files debfiles
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
// usage: ./bash_completion <FILE>
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"github.com/hpcng/warewulf/internal/app/wwctl"
|
|
||||||
"os"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
fh, err := os.Create(os.Args[1])
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
defer fh.Close()
|
|
||||||
|
|
||||||
if err := wwctl.GenBashCompletion(fh); err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
// Generate man pages for wwctl command.
|
|
||||||
// usage: ./man_page <DIRECTORY>
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"github.com/hpcng/warewulf/internal/app/wwctl"
|
|
||||||
"os"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
|
|
||||||
if err := wwctl.GenManTree(os.Args[1]); err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -6,18 +6,18 @@ import (
|
|||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
func CobraRunE(cmd *cobra.Command, args []string) (err error) {
|
||||||
myArg := "bash"
|
myArg := "bash"
|
||||||
if len(args) == 1 {
|
if len(args) == 1 {
|
||||||
myArg = args[0]
|
myArg = args[0]
|
||||||
}
|
}
|
||||||
switch myArg {
|
switch myArg {
|
||||||
case "zsh":
|
case "zsh":
|
||||||
cmd.GenZshCompletion(os.Stdout)
|
err = cmd.Parent().Parent().GenZshCompletion(os.Stdout)
|
||||||
case "fish":
|
case "fish":
|
||||||
cmd.GenFishCompletion(os.Stdout, true)
|
err = cmd.Parent().Parent().GenFishCompletion(os.Stdout, true)
|
||||||
default:
|
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 (
|
import (
|
||||||
"github.com/hpcng/warewulf/internal/app/wwctl/genconf/completions"
|
"github.com/hpcng/warewulf/internal/app/wwctl/genconf/completions"
|
||||||
|
"github.com/hpcng/warewulf/internal/app/wwctl/genconf/man"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -14,10 +15,12 @@ var (
|
|||||||
Aliases: []string{"cnf"},
|
Aliases: []string{"cnf"},
|
||||||
}
|
}
|
||||||
ListFull bool
|
ListFull bool
|
||||||
|
WWctlRoot *cobra.Command
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
baseCmd.AddCommand(completions.GetCommand())
|
baseCmd.AddCommand(completions.GetCommand())
|
||||||
|
baseCmd.AddCommand(man.GetCommand())
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRootCommand returns the root cobra.Command for the application.
|
// GetRootCommand returns the root cobra.Command for the application.
|
||||||
|
|||||||
@@ -15,9 +15,6 @@ import (
|
|||||||
"github.com/hpcng/warewulf/internal/pkg/help"
|
"github.com/hpcng/warewulf/internal/pkg/help"
|
||||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/cobra/doc"
|
|
||||||
|
|
||||||
"io"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -74,19 +71,3 @@ func rootPersistentPreRunE(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// External functions not used by the wwctl command line
|
|
||||||
|
|
||||||
// Generate Bash completion file
|
|
||||||
func GenBashCompletion(w io.Writer) error {
|
|
||||||
return rootCmd.GenBashCompletion(w)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate man pages
|
|
||||||
func GenManTree(fileName string) error {
|
|
||||||
header := &doc.GenManHeader{
|
|
||||||
Title: "WWCTL",
|
|
||||||
Section: "1",
|
|
||||||
}
|
|
||||||
return doc.GenManTree(rootCmd, header, fileName)
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user