heroku/hk — pull request #38 by bgentry (2013-12-13 00:26:56+00:00)
Title: Parse app flag globally but from command options

Instead of `hk -a myapp cmdname`, this reverts back to the `hk cmdname -a myapp` syntax. However, parsing the `-a app` param is still handled by the `func main()` rather than the subcommands or plugins.

```bash
➜ ./hk info -a myapp
Name: myapp
Owner: b@heroku.com
Region: us
Stack: cedar
Git URL: git@heroku.com:myapp.git
Web URL: http://myapp.herokuapp.com/
```

I've also opted to create a separate `Name` field on the `Command` struct to make it easier to add the `[-a ]` bit to usage instructions and to avoid having to parse it out of every command's `Usage` field.

One side effect of this change is that having a `-a` option in your `run` command is ambiguous:

```bash
➜ hk run bash -a hkdist
~ $
```

That actually does currently pull the `-a hkdist` option out of the command. I'd really like to avoid having this ambiguity. Here are the options I can think of:

1. Require the `-a` option to appear at the beginning of the command options (i.e. `hk run -a myapp bash` but not `hk run bash -a myapp`). This is much harder than it sounds because I have to know which flags are just bool flags and which are options w/ params.
2. Add special case handling in the app flag parsing to handle the `run` command. Yuck.
3. Require each Command that cares about the app option to specify it on the command's flags.

Thoughts?