Skip to content

Commit

Permalink
Initialise subcommands. Fixes #17.
Browse files Browse the repository at this point in the history
  • Loading branch information
alecthomas committed Nov 21, 2014
1 parent de11bc4 commit 261e7fb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ func (c *cmdGroup) init() error {
return fmt.Errorf("duplicate command '%s'", cmd.name)
}
seen[cmd.name] = true
if err := cmd.init(); err != nil {
return err
}
}
return nil
}
Expand Down
4 changes: 4 additions & 0 deletions parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ func (p *ParseContext) Peek() *Token {
func (p *ParseContext) Return(token *Token) {
p.Tokens = p.Tokens.Return(token)
}

func (p *ParseContext) String() string {
return p.SelectedCommand + ": " + p.Tokens.String()
}

0 comments on commit 261e7fb

Please sign in to comment.