JMS #4: Support for flag handling on command line

This commit is contained in:
Jeremy Saenz 2013-07-17 17:14:25 -07:00
parent ff4e064e21
commit 3b0fc03a67
2 changed files with 3 additions and 3 deletions

4
cli.go
View File

@ -24,7 +24,7 @@ func Run(args []string) {
set := flagSet(Flags)
set.Parse(args[1:])
context := Context{}
context := NewContext(set)
if len(args) > 1 {
name := args[1]
for _, c := range append(Commands, HelpCommand) {
@ -48,4 +48,4 @@ type Command struct {
Flags []Flag
}
type Handler func(context Context)
type Handler func(context *Context)

View File

@ -22,7 +22,7 @@ func init() {
HelpCommand.Action = ShowHelp
}
func ShowHelp(c Context) {
func ShowHelp(c *Context) {
helpTemplate := `NAME:
{{.Name}} - {{.Usage}}