You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -343,6 +432,34 @@ For general `--help` output, ***only*** the first sentence will be displayed. Ho
343
432
> **Note:** Pass an `Array` if you don't want internal assumptions. However, the first item is _always_ displayed in general help, so it's recommended to keep it short.
344
433
345
434
435
+
### prog.alias(...names)
436
+
437
+
Define one or more aliases for the current Command.
438
+
439
+
> **Important:** An error will be thrown if:<br>1) the program is in [Single Command Mode](#single-command-mode); or<br>2) `prog.alias` is called before any `prog.command`.
440
+
441
+
#### names
442
+
443
+
Type: `String`
444
+
445
+
The list of alternative names (aliases) for the current Command.<br>
446
+
For example, you may want to define shortcuts and/or common typos for the Command's full name.
447
+
448
+
> **Important:** Sade _does not_ check if the incoming `names` are already in use by other Commands or their aliases.<br>During conflicts, the Command with the same `name` is given priority, otherwise the first Command (according to Program order) with `name` as an alias is chosen.
449
+
450
+
The `prog.alias()` is append-only, so calling it multiple times within a Command context will _keep_ all aliases, including those initially passed via [`opts.alias`](#optsdefault).
451
+
452
+
```js
453
+
sade('bin')
454
+
.command('hello <name>', 'Greet someone by their name', {
455
+
alias: ['hey', 'yo']
456
+
})
457
+
.alias('hi', 'howdy')
458
+
.alias('hola', 'oi');
459
+
//=> hello aliases: hey, yo, hi, howdy, hola, oi
460
+
```
461
+
462
+
346
463
### prog.action(handler)
347
464
348
465
Attach a callback to the current Command.
@@ -392,7 +509,7 @@ Type: `String`
392
509
393
510
The example string to add. This will be included in the general or command-specific `--help` output.
394
511
395
-
> **Note:** Your example's `str` will be prefixed with your Programs's [`name`](#sadename).
512
+
> **Note:** Your example's `str` will be prefixed with your Program's [`name`](#sadename).
0 commit comments