diff --git a/libraries/ts-command-line/src/providers/ScopedCommandLineAction.ts b/libraries/ts-command-line/src/providers/ScopedCommandLineAction.ts index 53b35819160..fed3fa23377 100644 --- a/libraries/ts-command-line/src/providers/ScopedCommandLineAction.ts +++ b/libraries/ts-command-line/src/providers/ScopedCommandLineAction.ts @@ -11,9 +11,12 @@ interface IInternalScopedCommandLineParserOptions extends ICommandLineParserOpti readonly actionOptions: ICommandLineActionOptions; readonly unscopedActionParameters: ReadonlyArray; readonly onDefineScopedParameters: (commandLineParameterProvider: CommandLineParameterProvider) => void; - readonly onExecute: () => Promise; } +/** + * A CommandLineParser used exclusively to parse the scoped command-line parameters + * for a ScopedCommandLineAction. + */ class InternalScopedCommandLineParser extends CommandLineParser { private _internalOptions: IInternalScopedCommandLineParserOptions; @@ -40,12 +43,6 @@ class InternalScopedCommandLineParser extends CommandLineParser { protected onDefineParameters(): void { // No-op. Parameters are manually defined in the constructor. } - - protected async onExecute(): Promise { - await super.onExecute(); - // Redirect action execution to the provided callback - await this._internalOptions.onExecute(); - } } /** @@ -115,8 +112,7 @@ export abstract class ScopedCommandLineAction extends CommandLineAction { ...parserOptions, actionOptions: this._options, unscopedActionParameters: this.parameters, - onDefineScopedParameters: this.onDefineScopedParameters.bind(this), - onExecute: this.onExecute.bind(this) + onDefineScopedParameters: this.onDefineScopedParameters.bind(this) }); } @@ -153,6 +149,7 @@ export abstract class ScopedCommandLineAction extends CommandLineAction { // Call the scoped parser using only the scoped args. await this._scopedCommandLineParser.executeWithoutErrorHandling(scopedArgs); + await super._execute(); return; }