@pristine-ts/cli 2.0.17 → 2.0.18

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.
Files changed (96) hide show
  1. package/dist/lib/cjs/cli.configuration-keys.js +6 -0
  2. package/dist/lib/cjs/cli.configuration-keys.js.map +1 -1
  3. package/dist/lib/cjs/cli.module.js +13 -0
  4. package/dist/lib/cjs/cli.module.js.map +1 -1
  5. package/dist/lib/cjs/errors/cli-error-code.enum.js +10 -0
  6. package/dist/lib/cjs/errors/cli-error-code.enum.js.map +1 -1
  7. package/dist/lib/cjs/interfaces/command-parameter-choice.interface.js +3 -0
  8. package/dist/lib/cjs/interfaces/command-parameter-choice.interface.js.map +1 -0
  9. package/dist/lib/cjs/interfaces/command-parameter-choices-context.interface.js +3 -0
  10. package/dist/lib/cjs/interfaces/command-parameter-choices-context.interface.js.map +1 -0
  11. package/dist/lib/cjs/interfaces/command-parameter-choices-provider.interface.js +3 -0
  12. package/dist/lib/cjs/interfaces/command-parameter-choices-provider.interface.js.map +1 -0
  13. package/dist/lib/cjs/interfaces/interfaces.js +3 -0
  14. package/dist/lib/cjs/interfaces/interfaces.js.map +1 -1
  15. package/dist/lib/cjs/reporters/cli-error.reporter.js +11 -3
  16. package/dist/lib/cjs/reporters/cli-error.reporter.js.map +1 -1
  17. package/dist/lib/cjs/services/command-argument-error-formatter.js +146 -0
  18. package/dist/lib/cjs/services/command-argument-error-formatter.js.map +1 -0
  19. package/dist/lib/cjs/services/command-argument-resolver.js +1 -1
  20. package/dist/lib/cjs/services/command-argument-resolver.js.map +1 -1
  21. package/dist/lib/cjs/services/command-options-resolver.js +30 -37
  22. package/dist/lib/cjs/services/command-options-resolver.js.map +1 -1
  23. package/dist/lib/cjs/services/command-parameter-prompter.js +118 -38
  24. package/dist/lib/cjs/services/command-parameter-prompter.js.map +1 -1
  25. package/dist/lib/cjs/services/command-usage-renderer.js +81 -0
  26. package/dist/lib/cjs/services/command-usage-renderer.js.map +1 -0
  27. package/dist/lib/cjs/services/program-name-resolver.js +98 -0
  28. package/dist/lib/cjs/services/program-name-resolver.js.map +1 -0
  29. package/dist/lib/cjs/services/services.js +3 -0
  30. package/dist/lib/cjs/services/services.js.map +1 -1
  31. package/dist/lib/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  32. package/dist/lib/cjs/types/command-parameter-choices-list.type.js +3 -0
  33. package/dist/lib/cjs/types/command-parameter-choices-list.type.js.map +1 -0
  34. package/dist/lib/cjs/types/command-parameter-choices-resolver.type.js +3 -0
  35. package/dist/lib/cjs/types/command-parameter-choices-resolver.type.js.map +1 -0
  36. package/dist/lib/cjs/types/command-parameter-choices.type.js +3 -0
  37. package/dist/lib/cjs/types/command-parameter-choices.type.js.map +1 -0
  38. package/dist/lib/cjs/types/types.js +3 -0
  39. package/dist/lib/cjs/types/types.js.map +1 -1
  40. package/dist/lib/esm/cli.configuration-keys.js +6 -0
  41. package/dist/lib/esm/cli.configuration-keys.js.map +1 -1
  42. package/dist/lib/esm/cli.module.js +13 -0
  43. package/dist/lib/esm/cli.module.js.map +1 -1
  44. package/dist/lib/esm/errors/cli-error-code.enum.js +10 -0
  45. package/dist/lib/esm/errors/cli-error-code.enum.js.map +1 -1
  46. package/dist/lib/esm/interfaces/command-parameter-choice.interface.js +2 -0
  47. package/dist/lib/esm/interfaces/command-parameter-choice.interface.js.map +1 -0
  48. package/dist/lib/esm/interfaces/command-parameter-choices-context.interface.js +2 -0
  49. package/dist/lib/esm/interfaces/command-parameter-choices-context.interface.js.map +1 -0
  50. package/dist/lib/esm/interfaces/command-parameter-choices-provider.interface.js +2 -0
  51. package/dist/lib/esm/interfaces/command-parameter-choices-provider.interface.js.map +1 -0
  52. package/dist/lib/esm/interfaces/interfaces.js +3 -0
  53. package/dist/lib/esm/interfaces/interfaces.js.map +1 -1
  54. package/dist/lib/esm/reporters/cli-error.reporter.js +11 -3
  55. package/dist/lib/esm/reporters/cli-error.reporter.js.map +1 -1
  56. package/dist/lib/esm/services/command-argument-error-formatter.js +143 -0
  57. package/dist/lib/esm/services/command-argument-error-formatter.js.map +1 -0
  58. package/dist/lib/esm/services/command-argument-resolver.js +1 -1
  59. package/dist/lib/esm/services/command-argument-resolver.js.map +1 -1
  60. package/dist/lib/esm/services/command-options-resolver.js +31 -38
  61. package/dist/lib/esm/services/command-options-resolver.js.map +1 -1
  62. package/dist/lib/esm/services/command-parameter-prompter.js +120 -40
  63. package/dist/lib/esm/services/command-parameter-prompter.js.map +1 -1
  64. package/dist/lib/esm/services/command-usage-renderer.js +78 -0
  65. package/dist/lib/esm/services/command-usage-renderer.js.map +1 -0
  66. package/dist/lib/esm/services/program-name-resolver.js +62 -0
  67. package/dist/lib/esm/services/program-name-resolver.js.map +1 -0
  68. package/dist/lib/esm/services/services.js +3 -0
  69. package/dist/lib/esm/services/services.js.map +1 -1
  70. package/dist/lib/esm/tsconfig.tsbuildinfo +1 -1
  71. package/dist/lib/esm/types/command-parameter-choices-list.type.js +2 -0
  72. package/dist/lib/esm/types/command-parameter-choices-list.type.js.map +1 -0
  73. package/dist/lib/esm/types/command-parameter-choices-resolver.type.js +2 -0
  74. package/dist/lib/esm/types/command-parameter-choices-resolver.type.js.map +1 -0
  75. package/dist/lib/esm/types/command-parameter-choices.type.js +2 -0
  76. package/dist/lib/esm/types/command-parameter-choices.type.js.map +1 -0
  77. package/dist/lib/esm/types/types.js +3 -0
  78. package/dist/lib/esm/types/types.js.map +1 -1
  79. package/dist/types/cli.configuration-keys.d.ts +7 -0
  80. package/dist/types/errors/cli-error-code.enum.d.ts +10 -0
  81. package/dist/types/interfaces/command-parameter-choice.interface.d.ts +14 -0
  82. package/dist/types/interfaces/command-parameter-choices-context.interface.d.ts +17 -0
  83. package/dist/types/interfaces/command-parameter-choices-provider.interface.d.ts +20 -0
  84. package/dist/types/interfaces/interfaces.d.ts +3 -0
  85. package/dist/types/options/command-parameter.options.d.ts +30 -0
  86. package/dist/types/services/command-argument-error-formatter.d.ts +64 -0
  87. package/dist/types/services/command-options-resolver.d.ts +23 -13
  88. package/dist/types/services/command-parameter-prompter.d.ts +60 -31
  89. package/dist/types/services/command-usage-renderer.d.ts +35 -0
  90. package/dist/types/services/program-name-resolver.d.ts +21 -0
  91. package/dist/types/services/services.d.ts +3 -0
  92. package/dist/types/types/command-parameter-choices-list.type.d.ts +6 -0
  93. package/dist/types/types/command-parameter-choices-resolver.type.d.ts +9 -0
  94. package/dist/types/types/command-parameter-choices.type.d.ts +19 -0
  95. package/dist/types/types/types.d.ts +3 -0
  96. package/package.json +12 -12
@@ -21,8 +21,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
21
21
  };
22
22
  var CommandParameterPrompter_1;
23
23
  import "reflect-metadata";
24
- import { injectable } from "tsyringe";
25
- import { injectConfig, moduleScoped, UsageError } from "@pristine-ts/common";
24
+ import { inject, injectable } from "tsyringe";
25
+ import { injectConfig, moduleScoped, ServiceDefinitionTagEnum, UsageError } from "@pristine-ts/common";
26
26
  import { ClassMetadata, PropertyMetadata } from "@pristine-ts/metadata";
27
27
  import { Validator } from "@pristine-ts/class-validator";
28
28
  import { AutoDataMappingBuilderOptions, DataMapper } from "@pristine-ts/data-mapping";
@@ -34,34 +34,36 @@ import { CliDecoratorMetadataKeynameEnum } from "../enums/cli-decorator-metadata
34
34
  import { CliErrorCode } from "../errors/cli-error-code.enum";
35
35
  import { BooleanAnswerParser } from "../utils/boolean-answer-parser";
36
36
  /**
37
- * Applies a command's `@commandParameter` metadata to its raw, parsed arguments before they
38
- * are mapped onto the options instance and validated. Two things happen here:
37
+ * Applies a command's `@commandParameter` metadata to its raw, parsed arguments before they are
38
+ * mapped onto the options instance and validated. Two things happen here:
39
39
  *
40
- * 1. **Flag binding** — a parameter whose `flag` differs from its property name is copied
41
- * from the flag key onto the property key, so the by-property-name data mapper picks it
42
- * up. Two parameters resolving to the same flag is a programming error and throws.
43
- * 2. **Interactive fill** — a parameter that is absent and declares a `question` is asked
44
- * for interactively. Answers are rendered and checked against the property's declared
45
- * type (booleans as `(y/n)`, enum-constrained values list their choices) and coerced +
46
- * validated through the same mapper/validator the command pipeline uses, re-asking on an
47
- * invalid answer. Gated by the `InteractiveParameters` configuration and only run against
48
- * an interactive terminal; otherwise the absent value is left for validation to report.
40
+ * 1. **Flag binding** — a parameter whose `flag` differs from its property name is copied from
41
+ * the flag key onto the property key, so the by-property-name data mapper picks it up. Two
42
+ * parameters resolving to the same flag is a programming error and throws.
43
+ * 2. **Interactive fill** — a parameter that is absent and declares a `question` is asked for
44
+ * interactively. Values constrained to a set an explicit `choices`, or an `@IsIn` /
45
+ * `@IsEnum` — are picked from an arrow-key menu; booleans answer `(y/n)`; everything else is
46
+ * a free-text answer coerced + validated through the same mapper/validator the command
47
+ * pipeline uses, re-asking on an invalid answer. Gated by the `InteractiveParameters`
48
+ * configuration and only run against an interactive terminal; otherwise the absent value is
49
+ * left for validation to report.
49
50
  *
50
- * Parameters without a `@commandParameter` decorator are untouched, so commands that don't
51
- * use it pay nothing.
51
+ * Parameters without a `@commandParameter` decorator are untouched, so commands that don't use
52
+ * it pay nothing.
52
53
  */
53
54
  let CommandParameterPrompter = CommandParameterPrompter_1 = class CommandParameterPrompter {
54
- constructor(cliPrompt, cliOutput, validator, dataMapper, interactiveParametersEnabled) {
55
+ constructor(cliPrompt, cliOutput, validator, dataMapper, interactiveParametersEnabled, container) {
55
56
  this.cliPrompt = cliPrompt;
56
57
  this.cliOutput = cliOutput;
57
58
  this.validator = validator;
58
59
  this.dataMapper = dataMapper;
59
60
  this.interactiveParametersEnabled = interactiveParametersEnabled;
61
+ this.container = container;
60
62
  }
61
63
  /**
62
64
  * Returns a copy of `rawArgs` with aliased flags bound to their property and any missing,
63
- * question-carrying parameters filled in interactively. The input object is never mutated
64
- * the original command event payload stays intact.
65
+ * question-carrying parameters filled in interactively. The input object is never mutated
66
+ * the original command event payload stays intact.
65
67
  */
66
68
  fillMissingParameters(optionsType, rawArgs) {
67
69
  return __awaiter(this, void 0, void 0, function* () {
@@ -85,7 +87,7 @@ let CommandParameterPrompter = CommandParameterPrompter_1 = class CommandParamet
85
87
  if (this.interactiveParametersEnabled !== true || this.isInputInteractive() === false) {
86
88
  continue;
87
89
  }
88
- const value = yield this.promptForValue(optionsType, propertyKey, options);
90
+ const value = yield this.promptForValue(optionsType, propertyKey, flag, options, args);
89
91
  if (value !== undefined) {
90
92
  args[propertyKey] = value;
91
93
  }
@@ -94,8 +96,8 @@ let CommandParameterPrompter = CommandParameterPrompter_1 = class CommandParamet
94
96
  });
95
97
  }
96
98
  /**
97
- * Reads every `@commandParameter` off `optionsType`, resolving each to its effective flag
98
- * and detecting two parameters that would claim the same flag (a programming error).
99
+ * Reads every `@commandParameter` off `optionsType`, resolving each to its effective flag and
100
+ * detecting two parameters that would claim the same flag (a programming error).
99
101
  * @private
100
102
  */
101
103
  collectParameters(optionsType) {
@@ -122,35 +124,43 @@ let CommandParameterPrompter = CommandParameterPrompter_1 = class CommandParamet
122
124
  return parameters;
123
125
  }
124
126
  /**
125
- * Asks for a single parameter's value, rendering and validating it according to the
126
- * property's declared type:
127
+ * Asks for a single parameter's value, rendering and validating it according to the property's
128
+ * declared type:
127
129
  *
128
130
  * - sensitive values are read with the input masked and never trimmed;
131
+ * - a constrained value (explicit `choices`, or `@IsIn` / `@IsEnum`) is picked from an
132
+ * arrow-key menu, then coerced + validated like any typed value;
129
133
  * - booleans render as `(y/n)` and accept y/yes/true/1 & n/no/false/0;
130
- * - enum-constrained values (`@IsIn` / `@IsEnum`) list their choices;
131
134
  * - every other answer is coerced (via the data mapper) and validated (via the validator)
132
135
  * exactly as a typed flag would be, re-asking with the real constraint message when it
133
136
  * doesn't pass.
134
137
  *
135
- * Returns the coerced value, or `undefined` when the user enters nothing or the attempt
136
- * budget is exhausted — in which case the absent value falls through to validation.
138
+ * Returns the coerced value, or `undefined` when the user enters nothing or the attempt budget
139
+ * is exhausted — in which case the absent value falls through to validation.
137
140
  * @private
138
141
  */
139
- promptForValue(optionsType, propertyKey, options) {
142
+ promptForValue(optionsType, propertyKey, flag, options, args) {
140
143
  return __awaiter(this, void 0, void 0, function* () {
141
144
  var _a, _b;
142
145
  const sensitive = options.sensitive === true;
143
146
  const isBoolean = sensitive === false && Reflect.getMetadata("design:type", optionsType.prototype, propertyKey) === Boolean;
144
- const choices = (sensitive || isBoolean) ? undefined : this.getChoices(optionsType, propertyKey);
145
- const prompt = this.formatQuestion(this.decorateQuestion((_a = options.question) !== null && _a !== void 0 ? _a : "", isBoolean, choices));
147
+ // A constrained value is selected from an arrow-key menu, then coerced + validated the same
148
+ // way a typed flag would be. Secrets and booleans are never menus.
149
+ const menu = (sensitive || isBoolean) ? undefined : yield this.resolveChoices(optionsType, propertyKey, flag, options, args);
150
+ if (menu !== undefined) {
151
+ const selected = yield this.cliPrompt.select(this.menuMessage(options.question, flag), menu);
152
+ const outcome = yield this.coerceAndValidate(optionsType, propertyKey, selected);
153
+ return outcome.valid ? outcome.value : selected;
154
+ }
155
+ const prompt = this.formatQuestion(this.decorateQuestion((_a = options.question) !== null && _a !== void 0 ? _a : "", isBoolean, undefined));
146
156
  for (let attempt = 0; attempt < CommandParameterPrompter_1.MaxAttempts; attempt++) {
147
157
  // Secrets go through the masked reader and are never trimmed (a password may legitimately
148
158
  // contain surrounding whitespace); ordinary answers are trimmed.
149
159
  const raw = sensitive
150
160
  ? yield this.cliPrompt.readSecret(prompt)
151
161
  : (yield this.cliPrompt.readLine(prompt)).trim();
152
- // Nothing entered → leave the value unset so validation reports it (and a required
153
- // field surfaces the same way it would have without a prompt).
162
+ // Nothing entered → leave the value unset so validation reports it (and a required field
163
+ // surfaces the same way it would have without a prompt).
154
164
  if (raw.length === 0) {
155
165
  return undefined;
156
166
  }
@@ -174,6 +184,76 @@ let CommandParameterPrompter = CommandParameterPrompter_1 = class CommandParamet
174
184
  return undefined;
175
185
  });
176
186
  }
187
+ /**
188
+ * Resolves this parameter's selectable choices to a `{name, value}[]` menu, or `undefined`
189
+ * when it has none (free-text). Sources, in order: an explicit `@commandParameter({choices})`
190
+ * — a static list, a resolver function, or a DI provider class — else the `@IsIn` / `@IsEnum`
191
+ * set. An empty result is treated as "no menu".
192
+ * @private
193
+ */
194
+ resolveChoices(optionsType, propertyKey, flag, options, args) {
195
+ return __awaiter(this, void 0, void 0, function* () {
196
+ const list = yield this.resolveChoicesList(optionsType, propertyKey, flag, options, args);
197
+ if (list === undefined || list.length === 0) {
198
+ return undefined;
199
+ }
200
+ return list.map((choice) => typeof choice === "string" ? { name: choice, value: choice } : { name: choice.name, value: choice.value });
201
+ });
202
+ }
203
+ /**
204
+ * The raw choices list from the declared `choices` (static array / resolver function / DI
205
+ * provider class), falling back to the enum/`@IsIn` set when none is declared. Dynamic
206
+ * resolution failures degrade to free-text rather than crashing the prompt.
207
+ * @private
208
+ */
209
+ resolveChoicesList(optionsType, propertyKey, flag, options, args) {
210
+ return __awaiter(this, void 0, void 0, function* () {
211
+ const declared = options.choices;
212
+ // No explicit choices → the enum/`@IsIn` set (back-compat), which now drives a menu rather
213
+ // than a `(a/b/c)` text hint.
214
+ if (declared === undefined) {
215
+ return this.getChoices(optionsType, propertyKey);
216
+ }
217
+ if (Array.isArray(declared)) {
218
+ return declared;
219
+ }
220
+ const context = { args, propertyKey, flag };
221
+ try {
222
+ // A class constructor (DI provider) is distinguishable from a plain resolver function by
223
+ // its prototype carrying `getChoices`.
224
+ if (this.isChoicesProviderClass(declared)) {
225
+ // ── container.resolve, justified ───────────────────────────────────────────────────
226
+ // The provider class is named on the `@commandParameter` decorator at definition time;
227
+ // only at prompt time can we turn it into an instance (so it can inject a FileManager,
228
+ // HttpClient, …). Mirrors HelpCommand's late command resolution — the child container is
229
+ // constructor-injected, only the instantiation is deferred.
230
+ const provider = this.container.resolve(declared);
231
+ return yield provider.getChoices(context);
232
+ }
233
+ return yield declared(context);
234
+ }
235
+ catch (_a) {
236
+ this.cliOutput.writeLine(`Could not load choices for '${flag}'; enter the value directly.`);
237
+ return undefined;
238
+ }
239
+ });
240
+ }
241
+ /**
242
+ * Whether `candidate` is a provider *class* (vs a plain resolver function): a class carries a
243
+ * prototype with a `getChoices` method; an arrow/plain resolver does not.
244
+ * @private
245
+ */
246
+ isChoicesProviderClass(candidate) {
247
+ return typeof candidate === "function" && candidate.prototype != null && typeof candidate.prototype.getChoices === "function";
248
+ }
249
+ /**
250
+ * The menu heading: the parameter's `question` when set, else a neutral `Select <flag>`.
251
+ * @private
252
+ */
253
+ menuMessage(question, flag) {
254
+ const text = (question !== null && question !== void 0 ? question : "").trim();
255
+ return text.length > 0 ? text : `Select ${flag}`;
256
+ }
177
257
  /**
178
258
  * Maps a single raw answer onto a probe instance of `optionsType` and validates just that
179
259
  * property, returning the coerced value when it passes or the constraint messages when it
@@ -199,10 +279,9 @@ let CommandParameterPrompter = CommandParameterPrompter_1 = class CommandParamet
199
279
  });
200
280
  }
201
281
  /**
202
- * Flattens `class-validator`'s per-property constraint objects into plain, user-facing
203
- * lines. `@pristine-ts/class-validator` stores each constraint as `{keyname, message}`
204
- * rather than a bare string, so prefer `.message`, falling back so we never print
205
- * `[object Object]`.
282
+ * Flattens `class-validator`'s per-property constraint objects into plain, user-facing lines.
283
+ * `@pristine-ts/class-validator` stores each constraint as `{keyname, message}` rather than a
284
+ * bare string, so prefer `.message`, falling back so we never print `[object Object]`.
206
285
  * @private
207
286
  */
208
287
  describeErrors(errors) {
@@ -223,8 +302,8 @@ let CommandParameterPrompter = CommandParameterPrompter_1 = class CommandParamet
223
302
  /**
224
303
  * The allowed values declared by an `@IsIn([...])` or `@IsEnum(Enum)` on the property, for
225
304
  * display in the prompt. Reads `@pristine-ts/class-validator`'s stored validator instances
226
- * defensively — any shape mismatch just yields no menu (validation still rejects bad input
227
- * and re-asks). Returns undefined when the property isn't enum-constrained.
305
+ * defensively — any shape mismatch just yields no menu (validation still rejects bad input and
306
+ * re-asks). Returns undefined when the property isn't enum-constrained.
228
307
  * @private
229
308
  */
230
309
  getChoices(optionsType, propertyKey) {
@@ -275,8 +354,8 @@ let CommandParameterPrompter = CommandParameterPrompter_1 = class CommandParamet
275
354
  return process.stdin.isTTY === true;
276
355
  }
277
356
  /**
278
- * Ensures the rendered question ends with a trailing space so the typed answer doesn't butt
279
- * up against the prompt text.
357
+ * Ensures the rendered question ends with a trailing space so the typed answer doesn't butt up
358
+ * against the prompt text.
280
359
  * @private
281
360
  */
282
361
  formatQuestion(question) {
@@ -299,10 +378,11 @@ CommandParameterPrompter = CommandParameterPrompter_1 = __decorate([
299
378
  injectable(),
300
379
  moduleScoped(CliModuleKeyname),
301
380
  __param(4, injectConfig(CliConfigurationKeys.InteractiveParameters)),
381
+ __param(5, inject(ServiceDefinitionTagEnum.CurrentChildContainer)),
302
382
  __metadata("design:paramtypes", [CliPrompt,
303
383
  CliOutput,
304
384
  Validator,
305
- DataMapper, Boolean])
385
+ DataMapper, Boolean, Object])
306
386
  ], CommandParameterPrompter);
307
387
  export { CommandParameterPrompter };
308
388
  //# sourceMappingURL=command-parameter-prompter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"command-parameter-prompter.js","sourceRoot":"","sources":["../../../../src/services/command-parameter-prompter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AAEpC,OAAO,EAAC,YAAY,EAAE,YAAY,EAAE,UAAU,EAAC,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAC,aAAa,EAAE,gBAAgB,EAAC,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAC,SAAS,EAAC,MAAM,8BAA8B,CAAC;AACvD,OAAO,EAAC,6BAA6B,EAAE,UAAU,EAAC,MAAM,2BAA2B,CAAC;AACpF,OAAO,EAAC,gBAAgB,EAAC,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAC,oBAAoB,EAAC,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAC,SAAS,EAAC,MAAM,gCAAgC,CA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GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACvF,CAAC;QACH,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;OAGG;IACK,gBAAgB,CAAC,QAAgB,EAAE,SAAkB,EAAE,OAA6B;QAC1F,IAAI,SAAS,EAAE,CAAC;YACd,OAAO,GAAG,QAAQ,QAAQ,CAAC;QAC7B,CAAC;QACD,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAChD,OAAO,GAAG,QAAQ,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;QAC9C,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;;OAKG;IACK,kBAAkB;QACxB,OAAO,OAAO,CAAC,KAAK,CAAC,KAAK,KAAK,IAAI,CAAC;IACtC,CAAC;IAED;;;;OAIG;IACK,cAAc,CAAC,QAAgB;QACrC,OAAO,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,QAAQ,GAAG,CAAC;IAC5D,CAAC;;AA9QD;;;;GAIG;AACqB,kDAAyB,GAAG,8BAA8B,AAAjC,CAAkC;AAEnF;;;;GAIG;AACqB,oCAAW,GAAG,CAAC,AAAJ,CAAK;AAb7B,wBAAwB;IAFpC,UAAU,EAAE;IACZ,YAAY,CAAC,gBAAgB,CAAC;IAqB1B,WAAA,YAAY,CAAC,oBAAoB,CAAC,qBAAqB,CAAC,CAAA;qCAJ7B,SAAS;QACT,SAAS;QACT,SAAS;QACR,UAAU;GAnB9B,wBAAwB,CAgRpC"}
1
+ {"version":3,"file":"command-parameter-prompter.js","sourceRoot":"","sources":["../../../../src/services/command-parameter-prompter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,O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,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;;OAKG;IACK,kBAAkB;QACxB,OAAO,OAAO,CAAC,KAAK,CAAC,KAAK,KAAK,IAAI,CAAC;IACtC,CAAC;IAED;;;;OAIG;IACK,cAAc,CAAC,QAAgB;QACrC,OAAO,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,QAAQ,GAAG,CAAC;IAC5D,CAAC;;AAnWD;;;;GAIG;AACqB,kDAAyB,GAAG,8BAA8B,AAAjC,CAAkC;AAEnF;;;;GAIG;AACqB,oCAAW,GAAG,CAAC,AAAJ,CAAK;AAb7B,wBAAwB;IAFpC,UAAU,EAAE;IACZ,YAAY,CAAC,gBAAgB,CAAC;IAqB1B,WAAA,YAAY,CAAC,oBAAoB,CAAC,qBAAqB,CAAC,CAAA;IAIxD,WAAA,MAAM,CAAC,wBAAwB,CAAC,qBAAqB,CAAC,CAAA;qCAR3B,SAAS;QACT,SAAS;QACT,SAAS;QACR,UAAU;GAnB9B,wBAAwB,CAqWpC"}
@@ -0,0 +1,78 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var CommandUsageRenderer_1;
8
+ import "reflect-metadata";
9
+ import { injectable } from "tsyringe";
10
+ import { moduleScoped } from "@pristine-ts/common";
11
+ import { ClassMetadata, PropertyMetadata } from "@pristine-ts/metadata";
12
+ import { CliModuleKeyname } from "../cli.module.keyname";
13
+ import { CliDecoratorMetadataKeynameEnum } from "../enums/cli-decorator-metadata-keyname.enum";
14
+ /**
15
+ * Builds the one-line `Usage:` synopsis for a command from its options class, e.g.
16
+ *
17
+ * Usage: myapp key:add --name=<name> [--pubkey=<key-or-file>] [--rotate]
18
+ *
19
+ * Every declared option property becomes a token: required values render as `--flag=<hint>`,
20
+ * optional values as `[--flag=<hint>]`, and booleans as `[--flag]` (presence flags take no
21
+ * value). The placeholder defaults to the property name and can be overridden per parameter
22
+ * with `@commandParameter({valueHint})`; the flag honors `@commandParameter({flag})`.
23
+ *
24
+ * "Required" means the absence of an `@IsOptional()` condition on the property — the same
25
+ * signal the validator uses to decide whether a missing value is an error.
26
+ */
27
+ let CommandUsageRenderer = CommandUsageRenderer_1 = class CommandUsageRenderer {
28
+ /**
29
+ * Renders `Usage: <bin> <command> <tokens…>`. `binName` is the resolved program name (see
30
+ * `ProgramNameResolver`); `commandName` is the command's `name`.
31
+ */
32
+ render(optionsType, commandName, binName) {
33
+ const tokens = this.collectTokens(optionsType);
34
+ const synopsis = [binName, commandName, ...tokens].filter((part) => part.length > 0).join(" ");
35
+ return `Usage: ${synopsis}`;
36
+ }
37
+ /**
38
+ * One synopsis token per declared option property, in declaration order.
39
+ * @private
40
+ */
41
+ collectTokens(optionsType) {
42
+ var _a, _b;
43
+ const properties = ClassMetadata.getInformation(optionsType).properties;
44
+ const tokens = [];
45
+ for (const propertyKey of properties) {
46
+ const options = PropertyMetadata.getMetadata(optionsType.prototype, propertyKey, CliDecoratorMetadataKeynameEnum.CommandParameter);
47
+ const flag = (_a = options === null || options === void 0 ? void 0 : options.flag) !== null && _a !== void 0 ? _a : propertyKey;
48
+ // Booleans are presence flags — they never take a value.
49
+ if (Reflect.getMetadata("design:type", optionsType.prototype, propertyKey) === Boolean) {
50
+ tokens.push(`[--${flag}]`);
51
+ continue;
52
+ }
53
+ const body = `--${flag}=<${(_b = options === null || options === void 0 ? void 0 : options.valueHint) !== null && _b !== void 0 ? _b : propertyKey}>`;
54
+ tokens.push(this.isRequired(optionsType, propertyKey) ? body : `[${body}]`);
55
+ }
56
+ return tokens;
57
+ }
58
+ /**
59
+ * A property is required unless it carries an `@IsOptional()` condition. Read defensively: an
60
+ * unexpected metadata shape is treated as required (the safer default for a usage hint).
61
+ * @private
62
+ */
63
+ isRequired(optionsType, propertyKey) {
64
+ const conditions = PropertyMetadata.getMetadata(optionsType.prototype, propertyKey, CommandUsageRenderer_1.ConditionMetadataKey);
65
+ if (Array.isArray(conditions) === false) {
66
+ return true;
67
+ }
68
+ return conditions.some((condition) => { var _a; return ((_a = condition === null || condition === void 0 ? void 0 : condition.constructor) === null || _a === void 0 ? void 0 : _a.name) === "IsOptionalCondition"; }) === false;
69
+ }
70
+ };
71
+ /** `@pristine-ts/class-validator` stores each `@IsOptional()` as a condition here. */
72
+ CommandUsageRenderer.ConditionMetadataKey = "pristine-validator:condition";
73
+ CommandUsageRenderer = CommandUsageRenderer_1 = __decorate([
74
+ injectable(),
75
+ moduleScoped(CliModuleKeyname)
76
+ ], CommandUsageRenderer);
77
+ export { CommandUsageRenderer };
78
+ //# sourceMappingURL=command-usage-renderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-usage-renderer.js","sourceRoot":"","sources":["../../../../src/services/command-usage-renderer.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AAEpC,OAAO,EAAC,YAAY,EAAC,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAC,aAAa,EAAE,gBAAgB,EAAC,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAC,gBAAgB,EAAC,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAC,+BAA+B,EAAC,MAAM,8CAA8C,CAAC;AAG7F;;;;;;;;;;;;GAYG;AAGI,IAAM,oBAAoB,4BAA1B,MAAM,oBAAoB;IAI/B;;;OAGG;IACH,MAAM,CAAC,WAAkC,EAAE,WAAmB,EAAE,OAAe;Q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AAM,CAAC;IAChB,CAAC;IAED;;;;OAIG;IACK,UAAU,CAAC,WAAkC,EAAE,WAAmB;QACxE,MAAM,UAAU,GAAG,gBAAgB,CAAC,WAAW,CAAC,WAAW,CAAC,SAAS,EAAE,WAAW,EAAE,sBAAoB,CAAC,oBAAoB,CAAC,CAAC;QAC/H,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,KAAK,EAAE,CAAC;YACxC,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,WAAC,OAAA,CAAA,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,WAAW,0CAAE,IAAI,MAAK,qBAAqB,CAAA,EAAA,CAAC,KAAK,KAAK,CAAC;IAC1G,CAAC;;AAjDD,sFAAsF;AAC9D,yCAAoB,GAAG,8BAA8B,AAAjC,CAAkC;AAFnE,oBAAoB;IAFhC,UAAU,EAAE;IACZ,YAAY,CAAC,gBAAgB,CAAC;GAClB,oBAAoB,CAmDhC"}
@@ -0,0 +1,62 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
11
+ return function (target, key) { decorator(target, key, paramIndex); }
12
+ };
13
+ var ProgramNameResolver_1;
14
+ import { injectable } from "tsyringe";
15
+ import { injectConfig, moduleScoped } from "@pristine-ts/common";
16
+ import * as path from "path";
17
+ import { CliModuleKeyname } from "../cli.module.keyname";
18
+ import { CliConfigurationKeys } from "../cli.configuration-keys";
19
+ /**
20
+ * Resolves the program name shown in generated `Usage:` lines — the name the user actually
21
+ * typed, e.g. `myapp`, not the framework's `pristine`. Resolution is a hybrid, in priority
22
+ * order:
23
+ *
24
+ * 1. the `pristine.cli.binName` configuration, when set (an explicit override for odd launch
25
+ * shapes like `node dist/bin/cli.cjs`, where argv carries a file name);
26
+ * 2. otherwise `basename(argv[1])` with any `.cjs`/`.js`/`.mjs` extension stripped — the bin
27
+ * the user invoked, robust across global installs, `npx`, and local `.bin` shims;
28
+ * 3. otherwise the framework default `pristine`.
29
+ */
30
+ let ProgramNameResolver = ProgramNameResolver_1 = class ProgramNameResolver {
31
+ constructor(configuredBinName) {
32
+ this.configuredBinName = configuredBinName;
33
+ }
34
+ /**
35
+ * Returns the resolved program name. `argv` defaults to `process.argv`; it is a parameter so
36
+ * the REPL (and tests) can resolve a name from a synthetic argv.
37
+ */
38
+ resolve(argv = process.argv) {
39
+ var _a;
40
+ const configured = (_a = this.configuredBinName) === null || _a === void 0 ? void 0 : _a.trim();
41
+ if (configured) {
42
+ return configured;
43
+ }
44
+ const scriptPath = argv[1];
45
+ if (typeof scriptPath === "string" && scriptPath.length > 0) {
46
+ const base = path.basename(scriptPath, path.extname(scriptPath));
47
+ if (base.length > 0) {
48
+ return base;
49
+ }
50
+ }
51
+ return ProgramNameResolver_1.Fallback;
52
+ }
53
+ };
54
+ ProgramNameResolver.Fallback = "pristine";
55
+ ProgramNameResolver = ProgramNameResolver_1 = __decorate([
56
+ injectable(),
57
+ moduleScoped(CliModuleKeyname),
58
+ __param(0, injectConfig(CliConfigurationKeys.BinName)),
59
+ __metadata("design:paramtypes", [String])
60
+ ], ProgramNameResolver);
61
+ export { ProgramNameResolver };
62
+ //# sourceMappingURL=program-name-resolver.js.map
@@ -0,0 +1 @@
1
+ {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B,CAAC,OAAO,CAAC,CAAA;;GAJlC,mBAAmB,CA4B/B"}
@@ -1,4 +1,7 @@
1
+ export * from "./command-argument-error-formatter";
1
2
  export * from "./command-argument-resolver";
2
3
  export * from "./command-options-resolver";
3
4
  export * from "./command-parameter-prompter";
5
+ export * from "./command-usage-renderer";
6
+ export * from "./program-name-resolver";
4
7
  //# sourceMappingURL=services.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"services.js","sourceRoot":"","sources":["../../../../src/services/services.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC"}
1
+ {"version":3,"file":"services.js","sourceRoot":"","sources":["../../../../src/services/services.ts"],"names":[],"mappings":"AAAA,cAAc,oCAAoC,CAAC;AACnD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC"}