cmd

package
v2.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 20, 2021 License: Apache-2.0 Imports: 10 Imported by: 21

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Example = Sub{
	Name:  "example",
	Alias: "ex",
	Short: "Example command for testing",
	Flags: &ExampleFlags{},
	Args:  &ExampleArgs{},
	Run:   ExampleRun,
}

Example fulfills the "example" subcommand

View Source
var GenManPages = Sub{
	Name:   "gen-man-pages",
	Alias:  "gmp",
	Short:  "Generate man-pages for the root command and each sub-command",
	Run:    GenManPagesRun,
	Hidden: true,
}

GenManPages fulfills the "gen-man-pages" subcommand

View Source
var GenSingleLinks = Sub{
	Name:    "gen-single-links",
	Short:   "GenSingleLinks creates symlinks for a Single binary",
	Hidden:  true,
	SkipMan: true,
	Args:    &GenSingleLinksArgs{},
	Run:     GenSingleLinksRun,
}

GenSingleLinks fulfills the "gen-single-links" subcommand

View Source
var Help = Sub{
	Name:    "help",
	Alias:   "?",
	Short:   "Get help with a specific subcommand",
	SkipMan: true,
	Args:    &HelpArgs{},
	Run:     HelpRun,
}

Help fulfills the "help" subcommand

View Source
var Hidden = Sub{
	Name:   "hidden",
	Alias:  "hi",
	Short:  "Hidden command for testing",
	Hidden: true,
	Run:    HiddenRun,
}

Hidden fulfills the "hidden" subcommand

View Source
var Version = Sub{
	Name:    "version",
	Short:   "Print the version of this command",
	SkipMan: true,
	Run:     VersionRun,
}

Version fulfills the "hidden" subcommand

Functions

func ExampleRun

func ExampleRun(r *Root, c *Sub)

ExampleRun prints the usage for the requested command

func GenManPagesRun

func GenManPagesRun(r *Root, c *Sub)

GenManPagesRun prints the usage for the requested command

func GenSingleLinksRun

func GenSingleLinksRun(r *Root, c *Sub)

GenSingleLinksRun prints the usage for the requested command

func GenerateRootPage

func GenerateRootPage(r *Root) error

GenerateRootPage generates a man-page for the root command

func GenerateSubPage

func GenerateSubPage(r *Root, name string) error

GenerateSubPage generates a man-page for a single subcommand

func GenerateSubPages

func GenerateSubPages(r *Root) error

GenerateSubPages generates a man-page for every subcommand

func HelpRun

func HelpRun(r *Root, c *Sub)

HelpRun prints the usage for the requested command

func HiddenRun

func HiddenRun(r *Root, c *Sub)

HiddenRun prints the usage for the requested command

func PrintFlags

func PrintFlags(flags interface{})

PrintFlags writes out the flags in a struct

func Register

func Register(c *Sub)

Register a subcommand for the current root command

func VersionRun

func VersionRun(r *Root, c *Sub)

VersionRun prints the version and optional copyright for a command

Types

type ExampleArgs

type ExampleArgs struct {
	Args []uint8 `zero:"yes" desc:"Slice o' Args"`
}

ExampleArgs contains the arguments for the "example" subcommand

type ExampleFlags

type ExampleFlags struct {
	Boop bool `short:"b" long:"boop" desc:"You saw nothing"`
	Bop  bool `long:"bop" desc:"Ouch!"`
}

ExampleFlags contains the additional flags for the "example" subcommand

type GenSingleLinksArgs

type GenSingleLinksArgs struct {
	Path string `desc:"output dir for symlinks"`
}

GenSingleLinksArgs specifies the output path for the links

type HelpArgs

type HelpArgs struct {
	Subcommand string `desc:"Command to get help for"`
}

HelpArgs contains the arguments for the "help" subcommand

type Root

type Root struct {
	Name      string
	Short     string
	Flags     interface{}
	Single    bool
	Version   string
	Copyright string
	License   string
}

Root is the main command that supports multiple Sub commands

func (*Root) Run

func (r *Root) Run()

Run finds the appropriate CMD and executes it, or prints the global Usage

func (*Root) SubUsage

func (r *Root) SubUsage(c *Sub)

SubUsage prints a general usage statement for a subcommand

func (*Root) Usage

func (r *Root) Usage()

Usage prints the usage for this program

type Sub

type Sub struct {
	Name    string
	Alias   string
	Short   string
	Hidden  bool
	SkipMan bool
	Args    interface{}
	Flags   interface{}
	Run     func(r *Root, c *Sub)
}

Sub is a type for all commands

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL