Comparing version 2.0.0-rc.11 to 2.0.0-rc.12
@@ -52,2 +52,6 @@ import { CommandBuilder, RunState } from '../core'; | ||
/** | ||
* Register a listener that looks for an option and its followup argument. When Clipanion detects that this argument is present, the value will be pushed into the array represented in the property. | ||
*/ | ||
static Array(descriptor: string): <Context extends BaseContext>(prototype: Command<Context>, propertyName: string) => void; | ||
/** | ||
* Register a listener that takes all the positional arguments remaining and store them into the selected property. | ||
@@ -65,2 +69,6 @@ * Note that all methods affecting positional arguments are evaluated in the definition order; don't mess with it (for example sorting your properties in ascendent order might have adverse results). | ||
}): PropertyDecorator; | ||
/** | ||
* Register a listener that takes all the arguments remaining (including options and such) and store them into the selected property. | ||
* Note that all methods affecting positional arguments are evaluated in the definition order; don't mess with it (for example sorting your properties in ascendent order might have adverse results). | ||
*/ | ||
static Proxy(): <Context extends BaseContext>(prototype: Command<Context>, propertyName: string) => void; | ||
@@ -67,0 +75,0 @@ /** |
@@ -92,2 +92,23 @@ "use strict"; | ||
} | ||
/** | ||
* Register a listener that looks for an option and its followup argument. When Clipanion detects that this argument is present, the value will be pushed into the array represented in the property. | ||
*/ | ||
static Array(descriptor) { | ||
return (prototype, propertyName) => { | ||
const optNames = descriptor.split(`,`); | ||
this.registerDefinition(prototype, command => { | ||
command.addOption({ names: optNames, arity: 1 }); | ||
}); | ||
this.registerTransformer(prototype, (state, command) => { | ||
for (const { name, value } of state.options) { | ||
if (optNames.includes(name)) { | ||
// @ts-ignore: The property is meant to have been defined by the child class | ||
command[propertyName] = command[propertyName] || []; | ||
// @ts-ignore: The property is meant to have been defined by the child class | ||
command[propertyName].push(value); | ||
} | ||
} | ||
}); | ||
}; | ||
} | ||
static Rest({ required = 0 } = {}) { | ||
@@ -104,2 +125,6 @@ return (prototype, propertyName) => { | ||
} | ||
/** | ||
* Register a listener that takes all the arguments remaining (including options and such) and store them into the selected property. | ||
* Note that all methods affecting positional arguments are evaluated in the definition order; don't mess with it (for example sorting your properties in ascendent order might have adverse results). | ||
*/ | ||
static Proxy() { | ||
@@ -106,0 +131,0 @@ return (prototype, propertyName) => { |
{ | ||
"name": "clipanion", | ||
"version": "2.0.0-rc.11", | ||
"version": "2.0.0-rc.12", | ||
"main": "lib/advanced", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
64138
1562
0