stefanpenner/ember-cli — pull request #2565 by trabus (2014-11-26 01:23:46+00:00)
Title: Add options aliases (shorthands) to command model [wip]

### Overview
This PR adds support for command options aliases, as well as aliases for predefined options.

### Leveraging nopt
The [nopt library](https://github.com/npm/nopt) being used to parse arguments automatically creates implicit aliases. This explains why `ember serve -po=3333` works, but `ember serve -p=3333` doesn't. It resolves to the minimum number of characters to identify the unique option.

Nopt also has the ability to map a shortcut to an option with a predefined value. I was thinking we could have a pattern where the aliases array could take either strings or objects, where objects would represent shortcuts with predefined values. For the build command, we could alias environment to predefined values, like `ember build -prod` (would resolve to `ember build --environment=production`):
```
availableOptions: [
{ name: 'environment', type: String, default: 'development' , aliases: ['e', {'stage': 'stage'}, {'prod': 'production' }]},
{ name: 'output-path', type: path, default: 'dist/' },
{ name: 'watch', type: Boolean, default: false }
]
```
So essentially we get explicit aliases for more complex needs, combined with the default implicit aliases that nopt defines.

### Extended options
Currently any options defined in a blueprint's [availableOptions hook](https://github.com/stefanpenner/ember-cli/blob/master/blueprints/route/index.js#L10) [get merged in](https://github.com/stefanpenner/ember-cli/blob/master/lib/commands/generate.js#L108) so custom options can be added. This occurs after the initial processing of the command options, and so they currently don't work with the current approach.
I'll need to accommodate this use case before it can be merged.

### Predefined aliases
With support for predefined aliases being added, we should probably take advantage of them for some more common use cases, such as `ember build --environment=production` could become `ember build -prod`.
Any suggestions on some predefined aliases we'd like to add to CLI would be welcomed.

### Other
I still need to write some tests to support these changes, so there's that too.