Improved documentation

This commit is contained in:
Jeremy Saenz
2013-11-01 07:31:37 -07:00
parent 3c97f95b6a
commit 0d3c3f4497
5 changed files with 26 additions and 7 deletions

View File

@@ -7,15 +7,23 @@ import (
"strings"
)
// Command is a subcommand for a cli.App.
type Command struct {
Name string
ShortName string
Usage string
// The name of the command
Name string
// short name of the command. Typically one character
ShortName string
// A short description of the usage of this command
Usage string
// A longer explaination of how the command works
Description string
Action func(context *Context)
Flags []Flag
// The function to call when this command is invoked
Action func(context *Context)
// List of flags to parse
Flags []Flag
}
// Invokes the command given the context, parses ctx.Args() to generate command-specific flags
func (c Command) Run(ctx *Context) {
// append help to flags
c.Flags = append(
@@ -55,6 +63,7 @@ func (c Command) Run(ctx *Context) {
c.Action(context)
}
// Returns true if Command.Name or Command.ShortName matches given name
func (c Command) HasName(name string) bool {
return c.Name == name || c.ShortName == name
}