diff --git a/Readme.md b/Readme.md index 2e377bcc3..ed19cff63 100644 --- a/Readme.md +++ b/Readme.md @@ -543,6 +543,8 @@ Configuration options can be passed with the call to `.command()` and `.addComma remove the command from the generated help output. Specifying `isDefault: true` will run the subcommand if no other subcommand is specified ([example](./examples/defaultCommand.js)). +You can add alternative names for a command with `.alias()`. ([example](./examples/alias.js)) + For safety, `.addCommand()` does not automatically copy the inherited settings from the parent command. There is a helper routine `.copyInheritedSettings()` for copying the settings when they are wanted. ### Command-arguments diff --git a/examples/alias.js b/examples/alias.js new file mode 100644 index 000000000..ca9a9cd6d --- /dev/null +++ b/examples/alias.js @@ -0,0 +1,37 @@ +#!/usr/bin/env node + +// This example shows giving alternative names for a command. + +// const { Command } = require('commander'); // (normal include) +const { Command } = require('../'); // include commander in git clone of commander repo +const program = new Command(); + +program + .command('exec') + .argument('