This commit is contained in:
2026-02-13 23:49:12 +01:00
parent 206b8f08db
commit 2e02d6d763
36 changed files with 1816 additions and 4178 deletions

View File

@@ -50,7 +50,7 @@ class Argument {
}
/**
* @api private
* @package
*/
_concatValue(value, previous) {
@@ -98,7 +98,9 @@ class Argument {
this.argChoices = values.slice();
this.parseArg = (arg, previous) => {
if (!this.argChoices.includes(arg)) {
throw new InvalidArgumentError(`Allowed choices are ${this.argChoices.join(', ')}.`);
throw new InvalidArgumentError(
`Allowed choices are ${this.argChoices.join(', ')}.`,
);
}
if (this.variadic) {
return this._concatValue(arg, previous);
@@ -110,6 +112,8 @@ class Argument {
/**
* Make argument required.
*
* @returns {Argument}
*/
argRequired() {
this.required = true;
@@ -118,6 +122,8 @@ class Argument {
/**
* Make argument optional.
*
* @returns {Argument}
*/
argOptional() {
this.required = false;
@@ -130,15 +136,13 @@ class Argument {
*
* @param {Argument} arg
* @return {string}
* @api private
* @private
*/
function humanReadableArgName(arg) {
const nameOutput = arg.name() + (arg.variadic === true ? '...' : '');
return arg.required
? '<' + nameOutput + '>'
: '[' + nameOutput + ']';
return arg.required ? '<' + nameOutput + '>' : '[' + nameOutput + ']';
}
exports.Argument = Argument;