Documentation ¶
Overview ¶
Provides command handlers for the "blank" program.
Index ¶
- Constants
- Variables
- func Main(args []string)
- func RunWithHelp(c Command, args []string, p ...string)
- func UnquoteUsage(desc string) (name string, usage string)
- func WriteCommandUsage(w io.Writer, c Command, p ...string)
- func WriteFlagUsage(w io.Writer, f *Flag)
- type BlankCommand
- type Command
- type Flag
- type Flagged
- type HelpCommand
- type Info
- type Informative
- type MakeCommand
- type Named
- type NoFlags
- type NoHelp
- type Runnable
- type UpdateCommand
Constants ¶
const (
BlankCommandName = "blank"
)
const FlagLineFormat = " %-13s %s\n"
The fmt string used by WriteFlagUsage.
const HelpCommandName = "help"
const MakeCommandName = "make"
const UpdateCommandName = "update"
Variables ¶
var Blank = &BlankCommand{ &Info{ Line: "%s [options] [command [command_options]...]", Desc: "Program to generate blank dev projects.", }, []*Flag{ {Name: "-a", Desc: fmt.Sprintf("append `path` to %s", vBLANK_PATH)}, {Name: "-P", Desc: fmt.Sprintf("set `paths` as %s", vBLANK_PATH)}, }, []Command{ Make, Update, Help, }, }
The default "blank" command instance.
var Help = &HelpCommand{ info: &Info{ Line: "%s [command]", Desc: "Show help screen.", }, }
The default "help" subcommand instance.
var Make = &MakeCommand{ info: &Info{ Line: "%s [options] [target] ...", Desc: "Generate blank dev projects using makefiles.", }, }
The default "make" subcommand instance.
var Update = &UpdateCommand{ info: &Info{ Line: "%s [options] target [operation [path] json]...", Desc: "Update/patch config files.", }, flags: []*Flag{ { Name: "-i, --in", Desc: fmt.Sprintf("read target as `t` (%s)", fileTypesStr), }, { Name: "-o, --out", Desc: fmt.Sprintf("output as `t` (%s)", fileTypesStr), }, }, ops: []*Flag{ {Name: "-s", Desc: "set new values only"}, {Name: "-m", Desc: "merge values"}, {Name: "-a", Desc: `concatenate array values (implies "-m")`}, }, }
The default "update" subcommand instance.
Functions ¶
func RunWithHelp ¶
Run command c, intercepting first -h or --help argument.
func UnquoteUsage ¶
Extracts a back-quoted name from the usage string for a flag and returns it and the un-quoted usage.
Given "a `name` to show" it returns ("name", "a name to show"). If there are no back quotes, the name is an educated guess of the type of the flag's value, or the empty string if the flag is boolean.
func WriteCommandUsage ¶
Write program help screen.
The p argument is this command's parents' names, if any.
Types ¶
type BlankCommand ¶
type BlankCommand struct {
// contains filtered or unexported fields
}
The main "blank" command type.
func (*BlankCommand) Flags ¶
func (c *BlankCommand) Flags() []*Flag
func (*BlankCommand) Help ¶
func (c *BlankCommand) Help() string
Returns a help screen containing a list of sub-commands and environment variables.
func (*BlankCommand) Info ¶
func (c *BlankCommand) Info() *Info
func (*BlankCommand) Name ¶
func (c *BlankCommand) Name() string
func (*BlankCommand) Run ¶
func (c *BlankCommand) Run(args []string) error
type Flag ¶
Encapsulates only "informational" details about a flag. Used by WriteFlagUsage and WriteCommandUsage to display the help screen.
type Flagged ¶
type Flagged interface {
Flags() []*Flag
}
Provides the Flags method, for commands to provide a list of command-line flags.
type HelpCommand ¶
The "help" subcommand type.
func (*HelpCommand) Info ¶
func (c *HelpCommand) Info() *Info
func (*HelpCommand) Name ¶
func (c *HelpCommand) Name() string
func (*HelpCommand) Run ¶
func (c *HelpCommand) Run(args []string) error
type Informative ¶
Provides the Info and Help methods, for commands to provide detailed info in the help screen.
type MakeCommand ¶
type MakeCommand struct { NoFlags // contains filtered or unexported fields }
The "make" subcommand type.
func (*MakeCommand) Help ¶
func (c *MakeCommand) Help() string
func (*MakeCommand) Info ¶
func (c *MakeCommand) Info() *Info
func (*MakeCommand) Name ¶
func (c *MakeCommand) Name() string
func (*MakeCommand) Run ¶
func (c *MakeCommand) Run(args []string) error
type UpdateCommand ¶
type UpdateCommand struct { NoHelp // contains filtered or unexported fields }
The "update" subcommand type.
func (*UpdateCommand) Flags ¶
func (c *UpdateCommand) Flags() []*Flag
func (*UpdateCommand) Help ¶
func (c *UpdateCommand) Help() string
func (*UpdateCommand) Info ¶
func (c *UpdateCommand) Info() *Info
func (*UpdateCommand) Name ¶
func (c *UpdateCommand) Name() string
func (*UpdateCommand) Run ¶
func (c *UpdateCommand) Run(args []string) error