gonuts/commander — pull request #6 by jbenet (2013-12-18 14:02:58+00:00)
Title: Meld the Commander and Command abstractions.

I was searching for tools to handle command/subcommand parsing. I found `go-commander` (in particular this fork) to be pretty useful. However, I found the interface confusing. Why have Commanders and Commands as different things? Why not just have Commands with Subcommands? So I rewrote it to do that.

This pull-request proposes these changes. I'm new to go, have not tested this thoroughly, and am working off someone else's codebase, so my implementation is probably not that right one. That said, I think this is where I think `go-commander` should go, and thus using this PR to at least start that conversation.

Summary of Changes:
- united Commander/Command abstractions
- expose template defaults
- allow overriding of templates
- simpler flag handling
- use static/init commands in examples.

Real example of using this fork:

```go
var cmd_data = &commander.Command{
UsageLine: "data [] []",
Short: "dataset package manager",
Long: `data - dataset package manager
`,
Subcommands: []*commander.Command{
cmd_data_info,
cmd_data_list,
},
}

var cmd_data_info = &commander.Command{
UsageLine: "info ",
Short: "Show dataset information.",
Long: `data info - Show dataset information.

Returns the Datafile corresponding to and exits.
`,
Run: infoCmd,
}

var cmd_data_list = &commander.Command{
UsageLine: "info ",
Short: "Show dataset information.",
Long: `data info - Show dataset information.

Returns the Datafile corresponding to and exits.
`,
Run: listCmd,
}

func main() {
err := cmd_data.Dispatch(os.Args[1:])
if err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(1)
}
return
}
```

(flag set can be modified in the file's `init` function)