Repository: yargs/yargs
Pull request #648 (2016-10-06 18:22:06)

Update standard-version to version 3.0.0 🚀
Hello lovely humans,

[standard-version](https://www.npmjs.com/package/standard-version) just published its new version 3.0.0.

<table>
  <tr>
    <th align=left>
      State
    </th>
    <td>
      Update :rocket:
    </td>
  </tr>
  <tr>
    <th align=left>
      Dependency
    </td>
    <td>
      standard-version
    </td>
  </tr>
  <tr>
    <th align=left>
      New version
    </td>
    <td>
      3.0.0
    </td>
  </tr>
  <tr>
    <th align=left>
      Type
    </td>
    <td>
      devDependency
    </td>
  </tr>
</table>

This version is **not covered** by your **current version range**.

Without accepting this pull request your project will work just like it did before. There might be a bunch of new features, fixes and perf improvements that the maintainers worked on for you though.

I recommend you look into these changes and try to get onto the latest version of standard-version.
Given that you have a decent test suite, a passing build is a strong indicator that you can take advantage of these changes by merging the proposed change into your project. Otherwise this branch is a great starting point for you to work on the update.


Do you have any ideas how I could improve these pull requests? Did I report anything you think isn’t right?
Are you unsure about how things are supposed to work?

There is a collection of [frequently asked questions](https://greenkeeper.io/faq.html) and while I’m just a bot, there is a group of people who are happy to teach me new things. [Let them know](https://github.com/greenkeeperio/greenkeeper/issues/new).

Good luck with your project :sparkles:

You rock!

:palm_tree:

---
The new version differs by 47 commits .

- [`1727ea8`](https://github.com/conventional-changelog/standard-version/commit/1727ea8be0d94016291059ea04dc5288cacf0b67) <code>docs: remove repeated entries added to changelog</code>
- [`db55c66`](https://github.com/conventional-changelog/standard-version/commit/db55c66bb9cc4c57dd0538d295b3ba933a1d4a38) <code>chore(release): 3.0.0</code>
- [`432a100`](https://github.com/conventional-changelog/standard-version/commit/432a100e61bc80b2608c003875f6d61233beed6f) <code>chore: added release npm script</code>
- [`a903f4d`](https://github.com/conventional-changelog/standard-version/commit/a903f4d66caa8f5f334a85c1f21dce8a8d74ca48) <code>feat: added support for commitAll option in CLI (#121)</code>
- [`0ee080f`](https://github.com/conventional-changelog/standard-version/commit/0ee080f7c50f0cc2aa46663ea54f23160b13a507) <code>chore(package): update yargs to version 6.0.0 (#117)</code>
- [`ce268d9`](https://github.com/conventional-changelog/standard-version/commit/ce268d9a83a2b66c6a420067c802be44707b9ae2) <code>chore(package): update mocha to version 3.1.0 (#115)</code>
- [`832458a`](https://github.com/conventional-changelog/standard-version/commit/832458a476e6f40049634b95761ad034b52bd063) <code>docs(readme): add silent option example to code usage section</code>
- [`e68bd6b`](https://github.com/conventional-changelog/standard-version/commit/e68bd6b95ce6095f255d50aee8de30eee7996f7e) <code>test: add mocked error tests to achieve full test coverage</code>
- [`2a3fa61`](https://github.com/conventional-changelog/standard-version/commit/2a3fa6167bd84466485d7d7c3ea2e3a62e41a0ff) <code>feat(options): add --silent flag and option for squelching output</code>
- [`34a6a4e`](https://github.com/conventional-changelog/standard-version/commit/34a6a4ea23c1f56d923a8bbe004bf57fecc6badd) <code>feat: separate cli and defaults from base functionality</code>
- [`28ff65a`](https://github.com/conventional-changelog/standard-version/commit/28ff65a69cee682db05f899aafae8c2b6f1e4ccb) <code>chore: package.json engines field >=4.0, drop Node 0.10 and 0.12</code>
- [`e544339`](https://github.com/conventional-changelog/standard-version/commit/e544339c0a6dc35e6f663347e8cad1d98d0e07d8) <code>chore: add os, npm and editor related ignores to git (#113)</code>
- [`f7a4915`](https://github.com/conventional-changelog/standard-version/commit/f7a4915d26335e744066e89d734c2e6ea4b5e292) <code>fix(err): don't fail on stderr output, but print the output to stderr (#110)</code>
- [`d5d5e9e`](https://github.com/conventional-changelog/standard-version/commit/d5d5e9ed8f61d8025cf0ab4455937fc86a22bf22) <code>chore(editorconfig): add editorconfig (#112)</code>
- [`2ce4160`](https://github.com/conventional-changelog/standard-version/commit/2ce4160fcf4cb2c7b9338adf9d800c9d68128b21) <code>fix: check the private field in package.json(#102) (#103)</code>


There are 47 commits in total. See the [full diff](https://github.com/conventional-changelog/standard-version/compare/b6b2a75650e8f47e9bed5687e80ea66e0e66bf56...1727ea8be0d94016291059ea04dc5288cacf0b67).

---
This pull request was created by [greenkeeper.io](https://greenkeeper.io/).

<sub>Tired of seeing this sponsor message? :zap: `greenkeeper upgrade`</sub>


Patch:
diff --git a/README.md b/README.md
index 319be65..660661c 100644
--- a/README.md
+++ b/README.md
@@ -525,7 +525,11 @@ var argv = require('yargs')
 .command(module)
 ----------------
 
-Document the commands exposed by your application.
+Define the commands exposed by your application.
+
+`cmd` should be a string representing the command or an array of strings
+representing the command and its aliases. Read more about command aliases in the
+subsection below.
 
 Use `desc` to provide a description for each command your application accepts (the
 values stored in `argv._`).  Set `desc` to `false` to create a hidden command.
@@ -536,7 +540,8 @@ Optionally, you can provide a `builder` object to give hints about the
 options that your command accepts:
 
 ```js
-yargs.command('get', 'make a get HTTP request', {
+yargs
+  .command('get', 'make a get HTTP request', {
     url: {
       alias: 'u',
       default: 'http://yargs.js.org/'
@@ -558,7 +563,8 @@ options (if used) **always** apply globally, just like the
 with a `yargs` instance, and can be used to provide _advanced_ command specific help:
 
 ```js
-yargs.command('get', 'make a get HTTP request', function (yargs) {
+yargs
+  .command('get', 'make a get HTTP request', function (yargs) {
     return yargs.option('url', {
       alias: 'u',
       default: 'http://yargs.js.org/'
@@ -614,12 +620,78 @@ yargs.command('download <url> [files..]', 'download several files')
   .argv
 ```
 
+### Command Execution
+
+When a command is given on the command line, yargs will execute the following:
+
+1. push the command into the current context
+2. reset non-global configuration
+3. apply command configuration via the `builder`, if given
+4. parse and validate args from the command line, including positional args
+5. if validation succeeds, run the `handler` function, if given
+6. pop the command from the current context
+
+### Command Aliases
+
+You can define aliases for a command by putting the command and all of its
+aliases into an array.
+
+Alternatively, a command module may specify an `aliases` property, which may be
+a string or an array of strings. All aliases defined via the `command` property
+and the `aliases` property will be concatenated together.
+
+The first element in the array is considered the canonical command, which may
+define positional arguments, and the remaining elements in the array are
+considered aliases. Aliases inherit positional args from the canonical command,
+and thus any positional args defined in the aliases themselves are ignored.
+
+If either the canonical command or any of its aliases are given on the command
+line, the command will be executed.
+
+```js
+#!/usr/bin/env node
+require('yargs')
+  .command(['start [app]', 'run', 'up'], 'Start up an app', {}, (argv) => {
+    console.log('starting up the', argv.app || 'default', 'app')
+  })
+  .command({
+    command: 'configure <key> [value]',
+    aliases: ['config', 'cfg'],
+    desc: 'Set a config variable',
+    builder: (yargs) => yargs.default('value', 'true'),
+    handler: (argv) => {
+      console.log(`setting ${argv.key} to ${argv.value}`)
+    }
+  })
+  .demand(1)
+  .help()
+  .wrap(72)
+  .argv
+```
+
+```
+$ ./svc.js help
+Commands:
+  start [app]              Start up an app            [aliases: run, up]
+  configure <key> [value]  Set a config variable  [aliases: config, cfg]
+
+Options:
+  --help  Show help                                            [boolean]
+
+$ ./svc.js cfg concurrency 4
+setting concurrency to 4
+
+$ ./svc.js run web
+starting up the web app
+```
+
 ### Providing a Command Module
 
 For complicated commands you can pull the logic into a module. A module
 simply needs to export:
 
-* `exports.command`: string that executes this command when given on the command line, may contain positional args
+* `exports.command`: string (or array of strings) that executes this command when given on the command line, first string may contain positional args
+* `exports.aliases`: array of strings (or a single string) representing aliases of `exports.command`, positional args defined in an alias are ignored
 * `exports.describe`: string used as the description for the command in help text, use `false` for a hidden command
 * `exports.builder`: object declaring the options the command accepts, or a function accepting and returning a yargs instance
 * `exports.handler`: a function which will be passed the parsed argv.
diff --git a/lib/command.js b/lib/command.js
index 3d6615d..35b3077 100644
--- a/lib/command.js
+++ b/lib/command.js
@@ -8,27 +8,36 @@ module.exports = function (yargs, usage, validation) {
   const self = {}
 
   var handlers = {}
+  var aliasMap = {}
   self.addHandler = function (cmd, description, builder, handler) {
-    if (typeof cmd === 'object') {
-      const commandString = typeof cmd.command === 'string' ? cmd.command : moduleName(cmd)
-      self.addHandler(commandString, extractDesc(cmd), cmd.builder, cmd.handler)
+    var aliases = []
+    if (Array.isArray(cmd)) {
+      aliases = cmd.slice(1)
+      cmd = cmd[0]
+    } else if (typeof cmd === 'object') {
+      var command = (Array.isArray(cmd.command) || typeof cmd.command === 'string') ? cmd.command : moduleName(cmd)
+      if (cmd.aliases) command = [].concat(command).concat(cmd.aliases)
+      self.addHandler(command, extractDesc(cmd), cmd.builder, cmd.handler)
       return
     }
 
     // allow a module to be provided instead of separate builder and handler
     if (typeof builder === 'object' && builder.builder && typeof builder.handler === 'function') {
-      self.addHandler(cmd, description, builder.builder, builder.handler)
+      self.addHandler([cmd].concat(aliases), description, builder.builder, builder.handler)
       return
     }
 
+    var parsedCommand = parseCommand(cmd)
+    aliases = aliases.map(function (alias) {
+      alias = parseCommand(alias).cmd // remove positional args
+      aliasMap[alias] = parsedCommand.cmd
+      return alias
+    })
+
     if (description !== false) {
-      usage.command(cmd, description)
+      usage.command(cmd, description, aliases)
     }
 
-    // we should not register a handler if no
-    // builder is provided, e.g., user will
-    // handle command themselves with '_'.
-    var parsedCommand = parseCommand(cmd)
     handlers[parsedCommand.cmd] = {
       original: cmd,
       handler: handler,
@@ -112,7 +121,7 @@ module.exports = function (yargs, usage, validation) {
   }
 
   self.getCommands = function () {
-    return Object.keys(handlers)
+    return Object.keys(handlers).concat(Object.keys(aliasMap))
   }
 
   self.getCommandHandlers = function () {
@@ -121,7 +130,7 @@ module.exports = function (yargs, usage, validation) {
 
   self.runCommand = function (command, yargs, parsed) {
     var argv = parsed.argv
-    var commandHandler = handlers[command]
+    var commandHandler = handlers[command] || handlers[aliasMap[command]]
     var innerArgv = argv
     var currentContext = yargs.getContext()
     var parentCommands = currentContext.commands.slice()
@@ -204,6 +213,7 @@ module.exports = function (yargs, usage, validation) {
 
   self.reset = function () {
     handlers = {}
+    aliasMap = {}
     return self
   }
 
diff --git a/lib/usage.js b/lib/usage.js
index f362fb7..6d989ef 100644
--- a/lib/usage.js
+++ b/lib/usage.js
@@ -70,8 +70,8 @@ module.exports = function (yargs, y18n) {
   }
 
   var commands = []
-  self.command = function (cmd, description) {
-    commands.push([cmd, description || ''])
+  self.command = function (cmd, description, aliases) {
+    commands.push([cmd, description || '', aliases])
   }
   self.getCommands = function () {
     return commands
@@ -152,10 +152,15 @@ module.exports = function (yargs, y18n) {
       ui.div(__('Commands:'))
 
       commands.forEach(function (command) {
-        ui.div(
+        ui.span(
           {text: command[0], padding: [0, 2, 0, 2], width: maxWidth(commands, theWrap) + 4},
           {text: command[1]}
         )
+        if (command[2] && command[2].length) {
+          ui.div({text: '[' + __('aliases:') + ' ' + command[2].join(', ') + ']', padding: [0, 0, 0, 2], align: 'right'})
+        } else {
+          ui.div()
+        }
       })
 
       ui.div()
diff --git a/locales/de.json b/locales/de.json
index 86c874c..d805710 100644
--- a/locales/de.json
+++ b/locales/de.json
@@ -10,6 +10,7 @@
   "required": "erforderlich",
   "default:": "Standard:",
   "choices:": "Möglichkeiten:",
+  "aliases:": "Aliase:",
   "generated-value": "Generierter-Wert",
   "Not enough non-option arguments: got %s, need at least %s": "Nicht genügend Argumente ohne Optionen: %s vorhanden, mindestens %s benötigt",
   "Too many non-option arguments: got %s, maximum of %s": "Zu viele Argumente ohne Optionen: %s vorhanden, maximal %s erlaubt",
diff --git a/locales/en.json b/locales/en.json
index 59d4eb0..4917664 100644
--- a/locales/en.json
+++ b/locales/en.json
@@ -10,6 +10,7 @@
   "required": "required",
   "default:": "default:",
   "choices:": "choices:",
+  "aliases:": "aliases:",
   "generated-value": "generated-value",
   "Not enough non-option arguments: got %s, need at least %s": "Not enough non-option arguments: got %s, need at least %s",
   "Too many non-option arguments: got %s, maximum of %s": "Too many non-option arguments: got %s, maximum of %s",
diff --git a/locales/pl.json b/locales/pl.json
index 5e48ac6..1c834f6 100644
--- a/locales/pl.json
+++ b/locales/pl.json
@@ -10,6 +10,7 @@
   "required": "wymagany",
   "default:": "domyślny:",
   "choices:": "dostępne:",
+  "aliases:": "aliasy:",
   "generated-value": "wygenerowana-wartość",
   "Not enough non-option arguments: got %s, need at least %s": "Niewystarczająca ilość argumentów: otrzymano %s, wymagane co najmniej %s",
   "Too many non-option arguments: got %s, maximum of %s": "Zbyt duża ilość argumentów: otrzymano %s, wymagane co najwyżej %s",
@@ -33,5 +34,6 @@
   "Invalid JSON config file: %s": "Nieprawidłowy plik konfiguracyjny JSON: %s",
   "Path to JSON config file": "Ścieżka do pliku konfiguracyjnego JSON",
   "Show help": "Pokaż pomoc",
-  "Show version number": "Pokaż numer wersji"
+  "Show version number": "Pokaż numer wersji",
+  "Did you mean %s?": "Czy chodziło Ci o %s?"
 }
diff --git a/package.json b/package.json
index bab34dd..c06b0bd 100644
--- a/package.json
+++ b/package.json
@@ -38,7 +38,7 @@
     "nyc": "^8.1.0",
     "rimraf": "^2.5.0",
     "standard": "^8.2.0",
-    "standard-version": "^2.2.1",
+    "standard-version": "^3.0.0",
     "which": "^1.2.9"
   },
   "scripts": {


Test patch:
diff --git a/test/command.js b/test/command.js
index 6c405b5..b344e50 100644
--- a/test/command.js
+++ b/test/command.js
@@ -65,6 +65,20 @@ describe('Command', function () {
         })
         .argv
     })
+
+    it('ignores positional args for aliases', function () {
+      var y = yargs([])
+        .command(['foo [awesome]', 'wat <yo>'], 'my awesome command')
+      var command = y.getCommandInstance()
+      var handlers = command.getCommandHandlers()
+      handlers.foo.optional.should.include({
+        cmd: 'awesome',
+        variadic: false
+      })
+      handlers.foo.demanded.should.deep.equal([])
+      expect(handlers.wat).to.not.exist
+      command.getCommands().should.deep.equal(['foo', 'wat'])
+    })
   })
 
   describe('variadic', function () {
@@ -143,10 +157,23 @@ describe('Command', function () {
     it('accepts string, string as first 2 arguments', function () {
       var cmd = 'foo'
       var desc = 'i\'m not feeling very creative at the moment'
+      var aliases = []
 
       var y = yargs([]).command(cmd, desc)
       var commands = y.getUsageInstance().getCommands()
-      commands[0].should.deep.equal([cmd, desc])
+      commands[0].should.deep.equal([cmd, desc, aliases])
+    })
+
+    it('accepts array, string as first 2 arguments', function () {
+      var aliases = ['bar', 'baz']
+      var cmd = 'foo <qux>'
+      var desc = 'i\'m not feeling very creative at the moment'
+
+      var y = yargs([]).command([cmd].concat(aliases), desc)
+      var usageCommands = y.getUsageInstance().getCommands()
+      usageCommands[0].should.deep.equal([cmd, desc, aliases])
+      var cmdCommands = y.getCommandInstance().getCommands()
+      cmdCommands.should.deep.equal(['foo', 'bar', 'baz'])
     })
 
     it('accepts string, boolean as first 2 arguments', function () {
@@ -158,6 +185,18 @@ describe('Command', function () {
       commands.should.deep.equal([])
     })
 
+    it('accepts array, boolean as first 2 arguments', function () {
+      var aliases = ['bar', 'baz']
+      var cmd = 'foo <qux>'
+      var desc = false
+
+      var y = yargs([]).command([cmd].concat(aliases), desc)
+      var usageCommands = y.getUsageInstance().getCommands()
+      usageCommands.should.deep.equal([])
+      var cmdCommands = y.getCommandInstance().getCommands()
+      cmdCommands.should.deep.equal(['foo', 'bar', 'baz'])
+    })
+
     it('accepts function as 3rd argument', function () {
       var cmd = 'foo'
       var desc = 'i\'m not feeling very creative at the moment'
@@ -221,6 +260,7 @@ describe('Command', function () {
         builder: function (yargs) { return yargs },
         handler: function (argv) {}
       }
+      var aliases = []
 
       var y = yargs([]).command(module)
       var handlers = y.getCommandInstance().getCommandHandlers()
@@ -228,7 +268,7 @@ describe('Command', function () {
       handlers.foo.builder.should.equal(module.builder)
       handlers.foo.handler.should.equal(module.handler)
       var commands = y.getUsageInstance().getCommands()
-      commands[0].should.deep.equal([module.command, module.describe])
+      commands[0].should.deep.equal([module.command, module.describe, aliases])
     })
 
     it('accepts module (description key, builder function) as 1st argument', function () {
@@ -238,6 +278,7 @@ describe('Command', function () {
         builder: function (yargs) { return yargs },
         handler: function (argv) {}
       }
+      var aliases = []
 
       var y = yargs([]).command(module)
       var handlers = y.getCommandInstance().getCommandHandlers()
@@ -245,7 +286,7 @@ describe('Command', function () {
       handlers.foo.builder.should.equal(module.builder)
       handlers.foo.handler.should.equal(module.handler)
       var commands = y.getUsageInstance().getCommands()
-      commands[0].should.deep.equal([module.command, module.description])
+      commands[0].should.deep.equal([module.command, module.description, aliases])
     })
 
     it('accepts module (desc key, builder function) as 1st argument', function () {
@@ -255,6 +296,7 @@ describe('Command', function () {
         builder: function (yargs) { return yargs },
         handler: function (argv) {}
       }
+      var aliases = []
 
       var y = yargs([]).command(module)
       var handlers = y.getCommandInstance().getCommandHandlers()
@@ -262,7 +304,7 @@ describe('Command', function () {
       handlers.foo.builder.should.equal(module.builder)
       handlers.foo.handler.should.equal(module.handler)
       var commands = y.getUsageInstance().getCommands()
-      commands[0].should.deep.equal([module.command, module.desc])
+      commands[0].should.deep.equal([module.command, module.desc, aliases])
     })
 
     it('accepts module (false describe, builder function) as 1st argument', function () {
@@ -309,6 +351,7 @@ describe('Command', function () {
         },
         handler: function (argv) {}
       }
+      var aliases = []
 
       var y = yargs([]).command(module)
       var handlers = y.getCommandInstance().getCommandHandlers()
@@ -316,7 +359,7 @@ describe('Command', function () {
       handlers.foo.builder.should.equal(module.builder)
       handlers.foo.handler.should.equal(module.handler)
       var commands = y.getUsageInstance().getCommands()
-      commands[0].should.deep.equal([module.command, module.describe])
+      commands[0].should.deep.equal([module.command, module.describe, aliases])
     })
 
     it('accepts module (missing handler function) as 1st argument', function () {
@@ -329,6 +372,7 @@ describe('Command', function () {
           }
         }
       }
+      var aliases = []
 
       var y = yargs([]).command(module)
       var handlers = y.getCommandInstance().getCommandHandlers()
@@ -336,7 +380,86 @@ describe('Command', function () {
       handlers.foo.builder.should.equal(module.builder)
       expect(handlers.foo.handler).to.equal(undefined)
       var commands = y.getUsageInstance().getCommands()
-      commands[0].should.deep.equal([module.command, module.describe])
+      commands[0].should.deep.equal([module.command, module.describe, aliases])
+    })
+
+    it('accepts module (with command array) as 1st argument', function () {
+      var module = {
+        command: ['foo <qux>', 'bar', 'baz'],
+        describe: 'i\'m not feeling very creative at the moment',
+        builder: function (yargs) { return yargs },
+        handler: function (argv) {}
+      }
+
+      var y = yargs([]).command(module)
+      var handlers = y.getCommandInstance().getCommandHandlers()
+      handlers.foo.original.should.equal(module.command[0])
+      handlers.foo.builder.should.equal(module.builder)
+      handlers.foo.handler.should.equal(module.handler)
+      var usageCommands = y.getUsageInstance().getCommands()
+      usageCommands[0].should.deep.equal([module.command[0], module.describe, ['bar', 'baz']])
+      var cmdCommands = y.getCommandInstance().getCommands()
+      cmdCommands.should.deep.equal(['foo', 'bar', 'baz'])
+    })
+
+    it('accepts module (with command string and aliases array) as 1st argument', function () {
+      var module = {
+        command: 'foo <qux>',
+        aliases: ['bar', 'baz'],
+        describe: 'i\'m not feeling very creative at the moment',
+        builder: function (yargs) { return yargs },
+        handler: function (argv) {}
+      }
+
+      var y = yargs([]).command(module)
+      var handlers = y.getCommandInstance().getCommandHandlers()
+      handlers.foo.original.should.equal(module.command)
+      handlers.foo.builder.should.equal(module.builder)
+      handlers.foo.handler.should.equal(module.handler)
+      var usageCommands = y.getUsageInstance().getCommands()
+      usageCommands[0].should.deep.equal([module.command, module.describe, module.aliases])
+      var cmdCommands = y.getCommandInstance().getCommands()
+      cmdCommands.should.deep.equal(['foo', 'bar', 'baz'])
+    })
+
+    it('accepts module (with command array and aliases array) as 1st argument', function () {
+      var module = {
+        command: ['foo <qux>', 'bar'],
+        aliases: ['baz', 'nat'],
+        describe: 'i\'m not feeling very creative at the moment',
+        builder: function (yargs) { return yargs },
+        handler: function (argv) {}
+      }
+
+      var y = yargs([]).command(module)
+      var handlers = y.getCommandInstance().getCommandHandlers()
+      handlers.foo.original.should.equal(module.command[0])
+      handlers.foo.builder.should.equal(module.builder)
+      handlers.foo.handler.should.equal(module.handler)
+      var usageCommands = y.getUsageInstance().getCommands()
+      usageCommands[0].should.deep.equal([module.command[0], module.describe, ['bar', 'baz', 'nat']])
+      var cmdCommands = y.getCommandInstance().getCommands()
+      cmdCommands.should.deep.equal(['foo', 'bar', 'baz', 'nat'])
+    })
+
+    it('accepts module (with command string and aliases string) as 1st argument', function () {
+      var module = {
+        command: 'foo <qux>',
+        aliases: 'bar',
+        describe: 'i\'m not feeling very creative at the moment',
+        builder: function (yargs) { return yargs },
+        handler: function (argv) {}
+      }
+
+      var y = yargs([]).command(module)
+      var handlers = y.getCommandInstance().getCommandHandlers()
+      handlers.foo.original.should.equal(module.command)
+      handlers.foo.builder.should.equal(module.builder)
+      handlers.foo.handler.should.equal(module.handler)
+      var usageCommands = y.getUsageInstance().getCommands()
+      usageCommands[0].should.deep.equal([module.command, module.describe, ['bar']])
+      var cmdCommands = y.getCommandInstance().getCommands()
+      cmdCommands.should.deep.equal(['foo', 'bar'])
     })
   })
 
@@ -636,4 +759,16 @@ describe('Command', function () {
     })
     handlers.foo.demanded.should.have.lengthOf(0)
   })
+
+  it('executes a command via alias', function () {
+    var commandCalled = false
+    var argv = yargs('hi world')
+      .command(['hello <someone>', 'hi'], 'Say hello', {}, function (argv) {
+        commandCalled = true
+        argv.should.have.property('someone').and.equal('world')
+      })
+      .argv
+    argv.should.have.property('someone').and.equal('world')
+    commandCalled.should.be.true
+  })
 })
diff --git a/test/usage.js b/test/usage.js
index bc4fa7e..e5e83ed 100644
--- a/test/usage.js
+++ b/test/usage.js
@@ -1772,6 +1772,42 @@ describe('usage tests', function () {
         ''
       ])
     })
+
+    it('displays aliases for commands that have them (no wrap)', function () {
+      var r = checkUsage(function () {
+        return yargs('help')
+          .command(['copy <src> [dest]', 'cp', 'dupe'], 'Copy something')
+          .help().wrap(null)
+          .argv
+      })
+
+      r.logs[0].split('\n').should.deep.equal([
+        'Commands:',
+        '  copy <src> [dest]  Copy something  [aliases: cp, dupe]',
+        '',
+        'Options:',
+        '  --help  Show help  [boolean]',
+        ''
+      ])
+    })
+
+    it('displays aliases for commands that have them (with wrap)', function () {
+      var r = checkUsage(function () {
+        return yargs('help')
+          .command(['copy <src> [dest]', 'cp', 'dupe'], 'Copy something')
+          .help().wrap(80)
+          .argv
+      })
+
+      r.logs[0].split('\n').should.deep.equal([
+        'Commands:',
+        '  copy <src> [dest]  Copy something                          [aliases: cp, dupe]',
+        '',
+        'Options:',
+        '  --help  Show help                                                    [boolean]',
+        ''
+      ])
+    })
   })
 
   describe('epilogue', function () {