Skip to content

Commit c700f2b

Browse files
committed
PR feedback
1 parent 8e47338 commit c700f2b

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

libraries/ts-command-line/src/CommandLineParameter.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,9 @@ export class CommandLineChoiceParameter extends CommandLineParameter {
220220
const environmentValue: string | undefined = process.env[this.environmentVariable];
221221
if (environmentValue !== undefined && environmentValue !== '') {
222222
if (this.alternatives.indexOf(environmentValue) < 0) {
223-
throw new Error(`Invalid value for the environment variable ${this.environmentVariable}. Valid choices are: "`
224-
+ this.alternatives.join('", "')) + '"';
223+
const choices: string = '"' + this.alternatives.join('", "') + '"';
224+
throw new Error(`Invalid value "${environmentValue}" for the environment variable`
225+
+ ` ${this.environmentVariable}. Valid choices are: ${choices}`);
225226
}
226227
this._value = environmentValue;
227228
return;
@@ -284,8 +285,8 @@ export class CommandLineFlagParameter extends CommandLineParameter {
284285
const environmentValue: string | undefined = process.env[this.environmentVariable];
285286
if (environmentValue !== undefined && environmentValue !== '') {
286287
if (environmentValue !== '0' && environmentValue !== '1') {
287-
throw new Error(`Invalid value for the environment variable ${this.environmentVariable}.`
288-
+ ` Valid choices are 0 or 1.`);
288+
throw new Error(`Invalid value "${environmentValue}" for the environment variable`
289+
+ ` ${this.environmentVariable}. Valid choices are 0 or 1.`);
289290
}
290291
this._value = environmentValue === '1';
291292
return;
@@ -349,8 +350,8 @@ export class CommandLineIntegerParameter extends CommandLineParameterWithArgumen
349350
if (environmentValue !== undefined && environmentValue !== '') {
350351
const parsed: number = parseInt(environmentValue, 10);
351352
if (isNaN(parsed) || environmentValue.indexOf('.') >= 0) {
352-
throw new Error(`Invalid value for the environment variable ${this.environmentVariable}.`
353-
+ ' It must be an integer value.');
353+
throw new Error(`Invalid value "${environmentValue}" for the environment variable`
354+
+ ` ${this.environmentVariable}. It must be an integer value.`);
354355
}
355356
this._value = parsed;
356357
return;

libraries/ts-command-line/src/CommandLineParser.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,6 @@ export class CommandLineParserExitError extends Error {
4141
}
4242

4343
class CustomArgumentParser extends argparse.ArgumentParser {
44-
45-
constructor(options: argparse.ArgumentParserOptions | undefined) {
46-
super(options);
47-
}
48-
4944
public exit(status: number, message: string): void { // override
5045
throw new CommandLineParserExitError(status, message);
5146
}

0 commit comments

Comments
 (0)