@yamato-daiwa/es-extensions-nodejs 1.5.0 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,6 +9,7 @@ declare class ConsoleCommandsParser<TargetCommandsAndOptionsCombinations extends
9
9
  private readonly targetCommandOptions__eachOneWillBeRemovedOnceProcessed;
10
10
  private readonly targetCommandOptionsSpecification?;
11
11
  static parse<TargetCommandsAndOptionsCombinations extends ConsoleCommandsParser.GeneralizedCommandsAndOptionsCombinations>(argumentsVector: unknown, commandLineInterfaceSpecification: ConsoleCommandsParser.CommandLineInterfaceSpecification): ConsoleCommandsParser.ParsedCommand<TargetCommandsAndOptionsCombinations>;
12
+ static generateFullHelpReference(commandLineInterfaceSpecification: ConsoleCommandsParser.CommandLineInterfaceSpecification): string;
12
13
  static setLocalization(newLocalization: ConsoleCommandsParser.Localization): void;
13
14
  private constructor();
14
15
  private getParsedOptionsAndParameters;
@@ -16,7 +17,6 @@ declare class ConsoleCommandsParser<TargetCommandsAndOptionsCombinations extends
16
17
  private processNumberTypeOptionValue;
17
18
  private extractAndValidateParsedJSON5_ParameterValue;
18
19
  private static isCommandArgumentTheOption;
19
- private static generateFullHelpReference;
20
20
  private static generateSingleCommandHelpReference;
21
21
  }
22
22
  declare namespace ConsoleCommandsParser {
@@ -154,6 +154,36 @@ class ConsoleCommandsParser {
154
154
  ...dataHoldingSelfInstance.getParsedOptionsAndParameters()
155
155
  };
156
156
  }
157
+ static generateFullHelpReference(commandLineInterfaceSpecification) {
158
+ let accumulatingValue = `=== The CLI of ${commandLineInterfaceSpecification.applicationName} application ====================`;
159
+ if ((0, es_extensions_1.isNotUndefined)(commandLineInterfaceSpecification.defaultCommand)) {
160
+ accumulatingValue = "\nHas default command\n";
161
+ for (const [argumentName, argumentSpecification] of Object.entries(commandLineInterfaceSpecification.defaultCommand)) {
162
+ accumulatingValue = `${argumentName}: ${argumentSpecification.type}\n`;
163
+ }
164
+ }
165
+ if ((0, es_extensions_1.isNotUndefined)(commandLineInterfaceSpecification.commandPhrases)) {
166
+ accumulatingValue = `${accumulatingValue}\n=== Command phrases`;
167
+ for (const [commandPhrase, argumentsSpecification] of Object.entries(commandLineInterfaceSpecification.commandPhrases)) {
168
+ accumulatingValue = `${accumulatingValue}\n\n` +
169
+ `■ ${commandPhrase}\n`;
170
+ if ((0, es_extensions_1.isUndefined)(argumentsSpecification)) {
171
+ continue;
172
+ }
173
+ accumulatingValue = `${accumulatingValue}\n --- Arguments`;
174
+ for (const [argumentName, argumentSpecification] of Object.entries(argumentsSpecification)) {
175
+ accumulatingValue = `${accumulatingValue}\n` +
176
+ ` --${argumentName}:` +
177
+ `${(0, es_extensions_1.insertSubstring)(argumentSpecification.shortcut, {
178
+ modifier: (shortcut) => `\n Shortcut: -${shortcut}`
179
+ })}` +
180
+ `\n Type: ${argumentSpecification.type}` +
181
+ `${"required" in argumentSpecification ? `\n Is required: ${argumentSpecification.required}` : ""}`;
182
+ }
183
+ }
184
+ }
185
+ return accumulatingValue;
186
+ }
157
187
  static setLocalization(newLocalization) {
158
188
  ConsoleCommandsParser.localization = newLocalization;
159
189
  }
@@ -452,27 +482,6 @@ class ConsoleCommandsParser {
452
482
  static isCommandArgumentTheOption(consoleCommandArgument) {
453
483
  return consoleCommandArgument.startsWith("-");
454
484
  }
455
- static generateFullHelpReference(commandLineInterfaceSpecification) {
456
- let accumulatingValue = "";
457
- if ((0, es_extensions_1.isNotUndefined)(commandLineInterfaceSpecification.defaultCommand)) {
458
- accumulatingValue = "Has default command\n";
459
- for (const [argumentName, argumentSpecification] of Object.entries(commandLineInterfaceSpecification.defaultCommand)) {
460
- accumulatingValue = `${argumentName}: ${argumentSpecification.type}\n`;
461
- }
462
- }
463
- if ((0, es_extensions_1.isNotUndefined)(commandLineInterfaceSpecification.commandPhrases)) {
464
- for (const [commandPhrase, argumentsSpecification] of Object.entries(commandLineInterfaceSpecification.commandPhrases)) {
465
- accumulatingValue = `${accumulatingValue}${commandPhrase}:\n`;
466
- if ((0, es_extensions_1.isUndefined)(argumentsSpecification)) {
467
- continue;
468
- }
469
- for (const [argumentName, argumentSpecification] of Object.entries(argumentsSpecification)) {
470
- accumulatingValue = `${accumulatingValue}\n ${argumentName}: ${argumentSpecification.type}`;
471
- }
472
- }
473
- }
474
- return accumulatingValue;
475
- }
476
485
  static generateSingleCommandHelpReference({ commandPhrase, commandOptionsSpecification }) {
477
486
  let accumulatingValue = (0, es_extensions_1.isNotUndefined)(commandPhrase) ? commandPhrase : "(Default command)";
478
487
  for (const [argumentName, argumentSpecification] of Object.entries(commandOptionsSpecification)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yamato-daiwa/es-extensions-nodejs",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "description": "Additional to @yamato-daiwa/es-extensions functionality for Node.js environment. Helper functions and classes aimed to reduce the routine code. Build-in TypeScript type safety.",
5
5
  "keywords": [
6
6
  "nodejs",
@@ -30,7 +30,7 @@
30
30
  "@types/json5": "0.0.30",
31
31
  "@types/mocha": "9.1.1",
32
32
  "@types/node": "16.10.2",
33
- "@yamato-daiwa/style_guides": "0.0.14",
33
+ "@yamato-daiwa/style_guides": "0.0.16",
34
34
  "mocha": "10.0.0",
35
35
  "rimraf": "3.0.2",
36
36
  "ts-node": "10.8.1",