man-page
This commit is contained in:
parent
7e55ae4ca5
commit
5ab9a5bc3a
1
BUILD
1
BUILD
@ -9,6 +9,7 @@ go_library(
|
||||
visibility = ["//visibility:private"],
|
||||
deps = [
|
||||
"//src/undocker/internal/cmdlxcconfig:go_default_library",
|
||||
"//src/undocker/internal/cmdmanpage:go_default_library",
|
||||
"//src/undocker/internal/cmdrootfs:go_default_library",
|
||||
"@com_github_jessevdk_go_flags//:go_default_library",
|
||||
],
|
||||
|
9
internal/cmdmanpage/BUILD
Normal file
9
internal/cmdmanpage/BUILD
Normal file
@ -0,0 +1,9 @@
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["cmdmanpage.go"],
|
||||
importpath = "github.com/motiejus/code/undocker/internal/cmdmanpage",
|
||||
visibility = ["//src/undocker:__subpackages__"],
|
||||
deps = ["@com_github_jessevdk_go_flags//:go_default_library"],
|
||||
)
|
25
internal/cmdmanpage/cmdmanpage.go
Normal file
25
internal/cmdmanpage/cmdmanpage.go
Normal file
@ -0,0 +1,25 @@
|
||||
package cmdmanpage
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
|
||||
goflags "github.com/jessevdk/go-flags"
|
||||
)
|
||||
|
||||
type Command struct {
|
||||
parser *goflags.Parser
|
||||
stdout io.Writer
|
||||
}
|
||||
|
||||
func NewCommand(parser *goflags.Parser) *Command {
|
||||
return &Command{
|
||||
parser: parser,
|
||||
stdout: os.Stdout,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Command) Execute(args []string) error {
|
||||
c.parser.WriteManPage(c.stdout)
|
||||
return nil
|
||||
}
|
12
main.go
12
main.go
@ -5,18 +5,22 @@ import (
|
||||
|
||||
goflags "github.com/jessevdk/go-flags"
|
||||
"github.com/motiejus/code/undocker/internal/cmdlxcconfig"
|
||||
"github.com/motiejus/code/undocker/internal/cmdmanpage"
|
||||
"github.com/motiejus/code/undocker/internal/cmdrootfs"
|
||||
)
|
||||
|
||||
func main() {
|
||||
flags := goflags.NewParser(nil, goflags.Default)
|
||||
parser := goflags.NewParser(nil, goflags.Default)
|
||||
|
||||
rootfs := cmdrootfs.NewCommand()
|
||||
lxcconfig := cmdlxcconfig.NewCommand()
|
||||
flags.AddCommand("rootfs", rootfs.ShortDesc(), rootfs.LongDesc(), rootfs)
|
||||
flags.AddCommand("lxcconfig", lxcconfig.ShortDesc(), lxcconfig.LongDesc(), lxcconfig)
|
||||
manpage := cmdmanpage.NewCommand(parser)
|
||||
parser.AddCommand("rootfs", rootfs.ShortDesc(), rootfs.LongDesc(), rootfs)
|
||||
parser.AddCommand("lxcconfig", lxcconfig.ShortDesc(), lxcconfig.LongDesc(), lxcconfig)
|
||||
m, _ := parser.AddCommand("man-page", "", "", manpage)
|
||||
m.Hidden = true
|
||||
|
||||
_, err := flags.Parse()
|
||||
_, err := parser.Parse()
|
||||
if err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user