@rushstack/ts-command-line
Advanced tools
Comparing version 4.20.1 to 4.21.0
@@ -548,4 +548,3 @@ /** | ||
/** | ||
* The child class should implement this hook to define its command-line parameters, | ||
* e.g. by calling defineFlagParameter(). | ||
* @deprecated - Define parameters in the constructor | ||
*/ | ||
@@ -1152,13 +1151,6 @@ protected onDefineParameters?(): void; | ||
/* Excluded from this release type: _registerDefinedParameters */ | ||
/** | ||
* {@inheritdoc CommandLineParameterProvider.onDefineParameters} | ||
*/ | ||
protected onDefineParameters(): void; | ||
/* Excluded from this release type: _getScopedCommandLineParser */ | ||
/* Excluded from this release type: _defineParameter */ | ||
/** | ||
* The child class should implement this hook to define its unscoped command-line parameters, | ||
* e.g. by calling defineFlagParameter(). At least one scoping parameter must be defined. | ||
* Scoping parameters are defined by setting the parameterGroupName to | ||
* ScopedCommandLineAction.ScopingParameterGroupName. | ||
* @deprecated - Define parameters in the constructor | ||
*/ | ||
@@ -1165,0 +1157,0 @@ protected onDefineUnscopedParameters?(): void; |
@@ -298,4 +298,3 @@ import * as argparse from 'argparse'; | ||
/** | ||
* The child class should implement this hook to define its command-line parameters, | ||
* e.g. by calling defineFlagParameter(). | ||
* @deprecated - Define parameters in the constructor | ||
*/ | ||
@@ -302,0 +301,0 @@ protected onDefineParameters?(): void; |
@@ -59,6 +59,2 @@ import { SCOPING_PARAMETER_GROUP } from '../Constants'; | ||
/** | ||
* {@inheritdoc CommandLineParameterProvider.onDefineParameters} | ||
*/ | ||
protected onDefineParameters(): void; | ||
/** | ||
* Retrieves the scoped CommandLineParser, which is populated after the ScopedCommandLineAction is executed. | ||
@@ -71,6 +67,3 @@ * @internal | ||
/** | ||
* The child class should implement this hook to define its unscoped command-line parameters, | ||
* e.g. by calling defineFlagParameter(). At least one scoping parameter must be defined. | ||
* Scoping parameters are defined by setting the parameterGroupName to | ||
* ScopedCommandLineAction.ScopingParameterGroupName. | ||
* @deprecated - Define parameters in the constructor | ||
*/ | ||
@@ -77,0 +70,0 @@ protected onDefineUnscopedParameters?(): void; |
@@ -78,5 +78,14 @@ "use strict"; | ||
constructor(options) { | ||
var _a; | ||
super(options); | ||
this._options = options; | ||
this._scopingParameters = []; | ||
// Consume the remainder of the command-line, which will later be passed the scoped parser. | ||
// This will also prevent developers from calling this.defineCommandLineRemainder(...) since | ||
// we will have already defined it. | ||
this.defineCommandLineRemainder({ | ||
description: 'Scoped parameters. Must be prefixed with "--", ex. "-- --scopedParameter ' + | ||
'foo --scopedFlag". For more information on available scoped parameters, use "-- --help".' | ||
}); | ||
(_a = this.onDefineUnscopedParameters) === null || _a === void 0 ? void 0 : _a.call(this); | ||
} | ||
@@ -153,2 +162,7 @@ /** | ||
_registerDefinedParameters(state) { | ||
if (!this._scopingParameters.length) { | ||
throw new Error('No scoping parameters defined. At least one scoping parameter must be defined. ' + | ||
'Scoping parameters are defined by setting the parameterGroupName to ' + | ||
'ScopedCommandLineAction.ScopingParameterGroupName.'); | ||
} | ||
super._registerDefinedParameters(state); | ||
@@ -163,25 +177,2 @@ const { parentParameterNames } = state; | ||
/** | ||
* {@inheritdoc CommandLineParameterProvider.onDefineParameters} | ||
*/ | ||
onDefineParameters() { | ||
var _a; | ||
(_a = this.onDefineUnscopedParameters) === null || _a === void 0 ? void 0 : _a.call(this); | ||
if (!this._scopingParameters.length) { | ||
throw new Error('No scoping parameters defined. At least one scoping parameter must be defined. ' + | ||
'Scoping parameters are defined by setting the parameterGroupName to ' + | ||
'ScopedCommandLineAction.ScopingParameterGroupName.'); | ||
} | ||
if (this.remainder) { | ||
throw new Error('Unscoped remainder parameters are not allowed. Remainder parameters can only be defined on ' + | ||
'the scoped parameter provider in onDefineScopedParameters().'); | ||
} | ||
// Consume the remainder of the command-line, which will later be passed the scoped parser. | ||
// This will also prevent developers from calling this.defineCommandLineRemainder(...) since | ||
// we will have already defined it. | ||
this.defineCommandLineRemainder({ | ||
description: 'Scoped parameters. Must be prefixed with "--", ex. "-- --scopedParameter ' + | ||
'foo --scopedFlag". For more information on available scoped parameters, use "-- --help".' | ||
}); | ||
} | ||
/** | ||
* Retrieves the scoped CommandLineParser, which is populated after the ScopedCommandLineAction is executed. | ||
@@ -188,0 +179,0 @@ * @internal |
{ | ||
"name": "@rushstack/ts-command-line", | ||
"version": "4.20.1", | ||
"version": "4.21.0", | ||
"description": "An object-oriented command-line parser for TypeScript", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -77,9 +77,3 @@ # ts-command-line | ||
}); | ||
} | ||
protected onExecute(): Promise<void> { // abstract | ||
return BusinessLogic.doTheWork(this._force.value, this._protocol.value || "(none)"); | ||
} | ||
protected onDefineParameters(): void { // abstract | ||
this._force = this.defineFlagParameter({ | ||
@@ -99,2 +93,6 @@ parameterLongName: '--force', | ||
} | ||
protected async onExecute(): Promise<void> { // abstract | ||
await BusinessLogic.doTheWork(this._force.value, this._protocol.value || "(none)"); | ||
} | ||
} | ||
@@ -116,5 +114,3 @@ ``` | ||
this.addAction(new PushAction()); | ||
} | ||
protected onDefineParameters(): void { // abstract | ||
this._verbose = this.defineFlagParameter({ | ||
@@ -127,5 +123,5 @@ parameterLongName: '--verbose', | ||
protected onExecute(): Promise<void> { // override | ||
protected async onExecute(): Promise<void> { // override | ||
BusinessLogic.configureLogger(this._verbose.value); | ||
return super.onExecute(); | ||
await super.onExecute(); | ||
} | ||
@@ -139,3 +135,3 @@ } | ||
const commandLine: WidgetCommandLine = new WidgetCommandLine(); | ||
commandLine.execute(); | ||
commandLine.executeAsync(); | ||
``` | ||
@@ -234,3 +230,3 @@ | ||
// Parse the command line | ||
commandLineParser.execute().then(() => { | ||
commandLineParser.executeAsync().then(() => { | ||
console.log('The action is: ' + commandLineParser.selectedAction!.actionName); | ||
@@ -237,0 +233,0 @@ console.log('The force flag is: ' + action.getFlagParameter('--force').value); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
470462
5112
248