Documentation ¶
Index ¶
- Variables
- func ExampleRun(r *RootCMD, c *CMD)
- func GenFlags(man io.Writer, v interface{}) error
- func GenManPagesRun(r *RootCMD, c *CMD)
- func GenerateRootPage(r *RootCMD) error
- func GenerateSubPage(r *RootCMD, name string) error
- func GenerateSubPages(r *RootCMD) error
- func HelpRun(r *RootCMD, c *CMD)
- func HiddenRun(r *RootCMD, c *CMD)
- func PrintFlags(flags interface{})
- func Usage(r *RootCMD, c *CMD)
- type CMD
- type ExampleArgs
- type ExampleFlags
- type GenManPagesArgs
- type HelpArgs
- type HiddenArgs
- type RootCMD
Constants ¶
This section is empty.
Variables ¶
var Example = CMD{ Name: "example", Alias: "ex", Short: "Example command for testing", Flags: &ExampleFlags{}, Args: &ExampleArgs{}, Run: ExampleRun, }
Example fulfills the "example" subcommand
var GenManPages = CMD{ Name: "gen-man-pages", Alias: "gmp", Short: "Generate man-pages for the root command and each sub-command", Args: &GenManPagesArgs{}, Run: GenManPagesRun, Hidden: true, }
GenManPages fulfills the "gen-man-pages" subcommand
var Help = CMD{ Name: "help", Alias: "?", Short: "Get help with a specific subcommand", Args: &HelpArgs{}, Run: HelpRun, }
Help fulfills the "help" subcommand
var Hidden = CMD{ Name: "hidden", Alias: "hi", Short: "Hidden command for testing", Hidden: true, Args: &HiddenArgs{}, Run: HiddenRun, }
Hidden fulfills the "hidden" subcommand
Functions ¶
func ExampleRun ¶ added in v1.1.0
ExampleRun prints the usage for the requested command
func GenManPagesRun ¶ added in v1.1.0
GenManPagesRun prints the usage for the requested command
func GenerateRootPage ¶ added in v1.1.0
GenerateRootPage generates a man-page for the root command
func GenerateSubPage ¶ added in v1.1.0
GenerateSubPage generates a man-page for a single subcommand
func GenerateSubPages ¶ added in v1.1.0
GenerateSubPages generates a man-page for every subcommand
Types ¶
type CMD ¶
type CMD struct { Name string Alias string Short string Hidden bool Args interface{} Flags interface{} Run func(r *RootCMD, c *CMD) }
CMD is a type for all commands
type ExampleArgs ¶ added in v1.1.0
type ExampleArgs struct {
Args []string `desc:"Slice o' Args"`
}
ExampleArgs contains the arguments for the "example" subcommand
type ExampleFlags ¶ added in v1.1.0
type ExampleFlags struct {
Boop bool `short:"b" long:"boop" desc:"You saw nothing"`
}
ExampleFlags contains the additional flags for the "example" subcommand
type GenManPagesArgs ¶ added in v1.1.0
type GenManPagesArgs struct{}
GenManPagesArgs contains the arguments for the "gen-man-pages" subcommand
type HelpArgs ¶
type HelpArgs struct {
Subcommand string `desc:"Command to get help for"`
}
HelpArgs contains the arguments for the "help" subcommand
type HiddenArgs ¶ added in v1.1.0
type HiddenArgs struct{}
HiddenArgs contains the arguments for the "hidden" subcommand
type RootCMD ¶
type RootCMD struct { Name string Short string Subcommands map[string]*CMD Aliases map[string]string Flags interface{} }
RootCMD is the main command that runs everything
func (*RootCMD) RegisterCMD ¶
RegisterCMD add a sub-command to this program