cmd

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2019 License: Apache-2.0 Imports: 7 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

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

Help fulfills the "help" subcommand

Functions

func HelpRun

func HelpRun(r *RootCMD, c *CMD)

HelpRun prints the usage for the requested command

func PrintFlags

func PrintFlags(flags interface{})

PrintFlags writes out the flags in a struct

func Usage

func Usage(r *RootCMD, c *CMD)

Usage prints a general usage statement

Types

type CMD

type CMD struct {
	Name  string
	Alias string
	Short string
	Args  interface{}
	Run   func(r *RootCMD, c *CMD)
}

CMD is a type for all commands

type HelpArgs

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

HelpArgs contains the arguments for the "help" 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

func (r *RootCMD) RegisterCMD(c *CMD)

RegisterCMD add a sub-command to this program

func (*RootCMD) Run

func (r *RootCMD) Run()

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

func (*RootCMD) Usage

func (r *RootCMD) Usage()

Usage prints the usage for this program

Jump to

Keyboard shortcuts

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