Skip to content

Commit b8b2d01

Browse files
committed
feat: support abbreviated commands; fixes #17
1 parent a71440d commit b8b2d01

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/command.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@ abstract class Command {
2727
*/
2828
public static configure(commandName: string, yargs: Yargs, projectPkg: any, context?: any): Yargs {
2929
let command = commandName;
30+
let abbreviations = command.split('').map((letter, i) => command.substr(0, i + 1));
3031
if (this.params) {
3132
command += ` ${ this.params }`;
3233
}
3334
debug(`adding command: ${ command }`);
3435
return yargs.command({
3536
command,
36-
aliases: this.aliases,
37+
aliases: this.aliases.concat(abbreviations),
3738
describe: this.description,
3839
builder: (commandArgs: Yargs) => {
3940
debug(`building options for ${ commandName }`);
@@ -80,7 +81,7 @@ abstract class Command {
8081
/**
8182
* An array of possible aliases for this command's name
8283
*/
83-
public static aliases: string[];
84+
public static aliases: string[] = [];
8485

8586
/**
8687
* Description of what the command does. Displayed when the root help message prints

0 commit comments

Comments
 (0)