cli-kiss 0.2.2 → 0.2.3

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.
@@ -1,112 +1,88 @@
1
- import { Option, OptionParser, OptionUsage } from "./Option";
2
- import { Positional, PositionalParser, PositionalUsage } from "./Positional";
1
+ import { Option, OptionDecoder, OptionUsage } from "./Option";
2
+ import { Positional, PositionalDecoder, PositionalUsage } from "./Positional";
3
3
  import { ReaderArgs } from "./Reader";
4
4
 
5
5
  /**
6
- * Describes an operation the combination of options, positional arguments, and an
7
- * async execution handler that together form the core logic of a CLI command.
6
+ * Options, positionals, and an async handler that together form the logic of a CLI command.
8
7
  *
9
- * An `Operation` is created with {@link operation} and passed to
10
- * {@link command}, {@link commandWithSubcommands}, or {@link commandChained} to build
11
- * a full {@link Command}.
8
+ * Created with {@link operation} and passed to {@link command},
9
+ * {@link commandWithSubcommands}, or {@link commandChained}.
12
10
  *
13
- * @typeParam Input - The context value the handler receives at execution time (forwarded
14
- * from the parent command's context or from a preceding chained operation).
15
- * @typeParam Output - The value the handler produces. For leaf operations this is
16
- * typically `void`; for intermediate stages it is the payload forwarded to the next
17
- * command in a chain.
11
+ * @typeParam Context - Injected at execution time; forwarded to handlers. Use to inject dependencies.
12
+ * @typeParam Result - Value produced on execution; typically `void` for leaf commands.
18
13
  */
19
- export type Operation<Input, Output> = {
14
+ export type Operation<Context, Result> = {
20
15
  /**
21
- * Returns usage metadata (options and positionals) without consuming any arguments.
22
- * Called by the parent command factory when building the help/usage output.
16
+ * Returns usage metadata without consuming any arguments.
23
17
  */
24
18
  generateUsage(): OperationUsage;
25
19
  /**
26
- * Parses options and positionals from `readerArgs` and returns an
27
- * {@link OperationFactory} that can create a ready-to-execute
28
- * {@link OperationInstance}.
29
- *
30
- * Any parse error (unknown option, type mismatch, etc.) is captured and re-thrown
31
- * when {@link OperationFactory.createInstance} is called.
32
- *
33
- * @param readerArgs - The shared argument reader. Options are registered on it and
34
- * positionals are consumed in declaration order.
20
+ * Consumes args from `readerArgs` and returns an {@link OperationDecoder}.
35
21
  */
36
- createFactory(readerArgs: ReaderArgs): OperationFactory<Input, Output>;
22
+ consumeAndMakeDecoder(
23
+ readerArgs: ReaderArgs,
24
+ ): OperationDecoder<Context, Result>;
37
25
  };
38
26
 
39
27
  /**
40
- * Produced by {@link Operation.createFactory} after argument parsing.
41
- * Instantiating it finalises value extraction and produces an {@link OperationInstance}.
28
+ * Produced by {@link Operation.consumeAndMakeDecoder}.
42
29
  *
43
- * @typeParam Input - operation instance input type {@link Operation}.
44
- * @typeParam Output - operation instance output type {@link Operation}.
30
+ * @typeParam Context - See {@link Operation}.
31
+ * @typeParam Result - See {@link Operation}.
45
32
  */
46
- export type OperationFactory<Input, Output> = {
33
+ export type OperationDecoder<Context, Result> = {
47
34
  /**
48
- * Extracts the final parsed values for all options and returns an
49
- * {@link OperationInstance} ready for execution.
35
+ * Creates a ready-to-execute {@link OperationInterpreter}.
50
36
  *
51
- * @throws {@link TypoError} if any option or positional validation failed during
52
- * {@link Operation.createFactory}.
37
+ * @throws {@link TypoError} if parsing or decoding failed.
53
38
  */
54
- createInstance(): OperationInstance<Input, Output>;
39
+ decodeAndMakeInterpreter(): OperationInterpreter<Context, Result>;
55
40
  };
56
41
 
57
42
  /**
58
- * A fully parsed, ready-to-execute operation.
43
+ * A fully parsed, decoded and ready-to-execute operation.
59
44
  *
60
- * @typeParam Input - The value the caller must supply as context.
61
- * @typeParam Output - The value produced on successful execution.
45
+ * @typeParam Context - Caller-supplied context.
46
+ * @typeParam Result - Value produced on success.
62
47
  */
63
- export type OperationInstance<Input, Output> = {
48
+ export type OperationInterpreter<Context, Result> = {
64
49
  /**
65
- * Runs the operation handler with the provided input context and the parsed
66
- * option/positional values.
67
- *
68
- * @param input - Context from the parent command (or the root context supplied to
69
- * {@link runAndExit}).
70
- * @returns A promise resolving to the handler's return value.
50
+ * Executes with the provided context.
71
51
  */
72
- executeWithContext(input: Input): Promise<Output>;
52
+ executeWithContext(context: Context): Promise<Result>;
73
53
  };
74
54
 
75
55
  /**
76
- * Collected usage metadata produced by {@link Operation.generateUsage}.
77
- * Consumed by the parent command factory when building {@link CommandUsage}.
56
+ * Usage metadata produced by {@link Operation.generateUsage}.
57
+ * Consumed when building {@link CommandUsage}.
78
58
  */
79
59
  export type OperationUsage = {
80
- /** Usage descriptors for all options registered by this operation. */
60
+ /**
61
+ * Usage descriptors for all registered options.
62
+ */
81
63
  options: Array<OptionUsage>;
82
- /** Usage descriptors for all positionals declared by this operation, in order. */
64
+ /**
65
+ * Usage descriptors for all declared positionals, in order.
66
+ */
83
67
  positionals: Array<PositionalUsage>;
84
68
  };
85
69
 
86
70
  /**
87
- * Creates an {@link Operation} from a set of options, positionals, and an
88
- * async handler function.
71
+ * Creates an {@link Operation} from options, positionals, and an async handler.
89
72
  *
90
- * The `handler` receives:
91
- * - `context` the value passed down from the parent command.
92
- * - `inputs.options` an object whose keys match those declared in `inputs.options` and whose values are
93
- * the parsed option values.
94
- * - `inputs.positionals` — a tuple whose elements match `inputs.positionals` and whose
95
- * values are the parsed positional values, in declaration order.
73
+ * The `handler` receives the parent `context` and an `inputs` object with
74
+ * `options` (keyed by the same names declared in `inputs.options`) and
75
+ * `positionals` (a tuple in declaration order).
96
76
  *
97
- * @typeParam Context - The context type accepted by the handler.
98
- * @typeParam Result - The return type of the handler.
99
- * @typeParam Options - Object type mapping option keys to their parsed value types.
100
- * @typeParam Positionals - Tuple type of parsed positional value types, in order.
77
+ * @typeParam Context - Context type accepted by the handler.
78
+ * @typeParam Result - Return type of the handler.
79
+ * @typeParam Options - Map of option keys to parsed value types.
80
+ * @typeParam Positionals - Tuple of parsed positional value types, in order.
101
81
  *
102
- * @param inputs - Declares the options and positionals this operation accepts.
103
- * @param inputs.options - A map from arbitrary keys to {@link Option} descriptors.
104
- * The same keys appear in `handler`'s `inputs.options` argument.
105
- * @param inputs.positionals - An ordered array of {@link Positional} descriptors.
106
- * Their parsed values appear in `handler`'s `inputs.positionals` argument, in the
107
- * same order.
108
- * @param handler - The async function that implements the command logic. Receives the
109
- * execution context and all parsed inputs.
82
+ * @param inputs - Options and positionals this operation accepts.
83
+ * @param inputs.options - Map of keys to {@link Option} descriptors.
84
+ * @param inputs.positionals - Ordered array of {@link Positional} descriptors.
85
+ * @param handler - Async function implementing the command logic.
110
86
  * @returns An {@link Operation} ready to be composed into a command.
111
87
  *
112
88
  * @example
@@ -160,25 +136,29 @@ export function operation<
160
136
  }
161
137
  return { options: optionsUsage, positionals: positionalsUsage };
162
138
  },
163
- createFactory(readerArgs: ReaderArgs) {
164
- const optionsGetters: Record<string, OptionParser<any>> = {};
139
+ consumeAndMakeDecoder(readerArgs: ReaderArgs) {
140
+ const optionsDecoders: Record<string, OptionDecoder<any>> = {};
165
141
  for (const optionKey in inputs.options) {
166
142
  const optionInput = inputs.options[optionKey]!;
167
- optionsGetters[optionKey] = optionInput.createParser(readerArgs);
143
+ optionsDecoders[optionKey] =
144
+ optionInput.registerAndMakeDecoder(readerArgs);
168
145
  }
169
- const positionalsParsers: Array<PositionalParser<any>> = [];
146
+ const positionalsDecoders: Array<PositionalDecoder<any>> = [];
170
147
  for (const positionalInput of inputs.positionals) {
171
- positionalsParsers.push(positionalInput.createParser(readerArgs));
148
+ positionalsDecoders.push(
149
+ positionalInput.consumeAndMakeDecoder(readerArgs),
150
+ );
172
151
  }
173
152
  return {
174
- createInstance() {
153
+ decodeAndMakeInterpreter() {
175
154
  const optionsValues: any = {};
176
- for (const optionKey in optionsGetters) {
177
- optionsValues[optionKey] = optionsGetters[optionKey]!.parseValue();
155
+ for (const optionKey in optionsDecoders) {
156
+ optionsValues[optionKey] =
157
+ optionsDecoders[optionKey]!.getAndDecodeValue();
178
158
  }
179
159
  const positionalsValues: any = [];
180
- for (const positionalParser of positionalsParsers) {
181
- positionalsValues.push(positionalParser.parseValue());
160
+ for (const positionalDecoder of positionalsDecoders) {
161
+ positionalsValues.push(positionalDecoder.decodeValue());
182
162
  }
183
163
  return {
184
164
  executeWithContext(context: Context) {
package/src/lib/Option.ts CHANGED
@@ -10,89 +10,78 @@ import {
10
10
  } from "./Typo";
11
11
 
12
12
  /**
13
- * Describes a single CLI option (a flag or a valued option) together with its parsing
14
- * and usage-generation logic.
13
+ * A CLI option (flag or valued) with its parsing and usage-generation logic.
15
14
  *
16
- * Options are created with {@link optionFlag}, {@link optionSingleValue}, or
17
- * {@link optionRepeatable} and are passed via the `options` map of {@link operation}.
15
+ * Created with {@link optionFlag}, {@link optionSingleValue}, or
16
+ * {@link optionRepeatable} and passed via the `options` map of {@link operation}.
18
17
  *
19
- * @typeParam Value - The TypeScript type of the parsed option value.
20
- * - `boolean` for flags created with {@link optionFlag}.
21
- * - `T` for single-value options created with {@link optionSingleValue}.
22
- * - `Array<T>` for repeatable options created with {@link optionRepeatable}.
18
+ * @typeParam Value - Decoded value type.
23
19
  */
24
20
  export type Option<Value> = {
25
- /** Returns human-readable metadata used to render the `Options:` section of help. */
21
+ /**
22
+ * Returns metadata used to render the `Options:` section of help.
23
+ */
26
24
  generateUsage(): OptionUsage;
27
25
  /**
28
- * Registers the option on `readerOptions` so the argument reader recognises it, and
29
- * returns an {@link OptionParser} that can later retrieve the parsed value(s).
30
- *
31
- * @param readerOptions - The shared {@link ReaderArgs} that will parse the raw
32
- * command-line tokens.
26
+ * Registers the option on `readerOptions` and returns an {@link OptionDecoder}.
33
27
  */
34
- createParser(readerOptions: ReaderOptions): OptionParser<Value>;
28
+ registerAndMakeDecoder(readerOptions: ReaderOptions): OptionDecoder<Value>;
35
29
  };
36
30
 
37
31
  /**
38
- * Retrieves the parsed value for a registered option after argument parsing is complete.
32
+ * Produced by {@link Option.registerAndMakeDecoder}.
39
33
  *
40
- * Returned by {@link Option.createParser} and called by {@link OperationFactory.createInstance}.
41
- *
42
- * @typeParam Value - The TypeScript type of the parsed value.
34
+ * @typeParam Value - Decoded value type.
43
35
  */
44
- export type OptionParser<Value> = {
45
- parseValue(): Value;
36
+ export type OptionDecoder<Value> = {
37
+ /**
38
+ * Returns the decoded option value.
39
+ *
40
+ * @throws {@link TypoError} if decoding failed.
41
+ */
42
+ getAndDecodeValue(): Value;
46
43
  };
47
44
 
48
45
  /**
49
- * Human-readable metadata for a single CLI option, used to render the `Options:` section
46
+ * Human-readable metadata for a single option, used to render the `Options:` section
50
47
  * of the help output produced by {@link usageToStyledLines}.
51
48
  */
52
49
  export type OptionUsage = {
53
- /** Short description of what the option does. */
54
- description: string | undefined;
55
50
  /**
56
- * Optional supplementary note shown in parentheses next to the description.
57
- * Suitable for short caveats such as `"required"` or `"defaults to 42"`.
51
+ * Long-form name without `--` (e.g. `"verbose"`).
58
52
  */
59
- hint: string | undefined;
53
+ long: Lowercase<string>;
60
54
  /**
61
- * The primary long-form name of the option, without the `--` prefix (e.g. `"verbose"`).
62
- * The user passes this as `--verbose` on the command line.
55
+ * Short-form name without `-` (e.g. `"v"`).
63
56
  */
64
- long: Lowercase<string>; // TODO - better type for long option names ?
57
+ short: string | undefined;
65
58
  /**
66
- * The optional short-form name of the option, without the `-` prefix (e.g. `"v"`).
67
- * The user passes this as `-v` on the command line.
59
+ * Help text in usage.
68
60
  */
69
- short: string | undefined;
61
+ description: string | undefined;
62
+ /**
63
+ * Short note shown in parentheses.
64
+ */
65
+ hint: string | undefined;
70
66
  /**
71
- * The value placeholder label shown after the long option name in the help output
72
- * (e.g. `"<FILE>"`). `undefined` for flags that take no value.
67
+ * Value placeholder in help (e.g. `"<FILE>"`). `undefined` for flags.
73
68
  */
74
69
  label: Uppercase<string> | undefined;
75
70
  };
76
71
 
77
72
  /**
78
- * Creates a boolean flag option an option that the user passes without a value (e.g.
79
- * `--verbose`) to signal `true`, or can explicitly set with `--flag=true` / `--flag=no`.
73
+ * Creates a boolean flag option (`--verbose`, optionally `--flag=no`).
80
74
  *
81
- * **Parsing rules:**
82
- * - Absent `false` (or the return value of `default()` when provided).
83
- * - `--flag` / `--flag=true` / `--flag=yes` → `true`.
84
- * - `--flag=false` / `--flag=no` → `false`.
85
- * - Specified more than once → {@link TypoError} ("Must not be set multiple times").
75
+ * Parsing: absent → `false`; `--flag` / `--flag=yes` → `true`; `--flag=no` → `false`;
76
+ * specified more than once {@link TypoError}.
86
77
  *
87
- * @param definition - Configuration for the flag.
88
- * @param definition.long - Primary long-form name (without `--`). Must be lowercase.
89
- * @param definition.short - Optional short-form name (without `-`).
90
- * @param definition.description - Human-readable description for the help output.
91
- * @param definition.hint - Optional supplementary note shown in parentheses.
92
- * @param definition.aliases - Additional long/short names that the parser also
93
- * recognises as this flag.
94
- * @param definition.default - Factory for the default value when the flag is absent.
95
- * Defaults to `() => false` when omitted.
78
+ * @param definition - Flag configuration.
79
+ * @param definition.long - Long-form name (without `--`).
80
+ * @param definition.short - Short-form name (without `-`).
81
+ * @param definition.description - Help text.
82
+ * @param definition.hint - Short note shown in parentheses.
83
+ * @param definition.aliases - Additional names.
84
+ * @param definition.default - Default when absent. Defaults to `() => false`.
96
85
  * @returns An {@link Option}`<boolean>`.
97
86
  *
98
87
  * @example
@@ -123,13 +112,13 @@ export function optionFlag(definition: {
123
112
  label: undefined,
124
113
  };
125
114
  },
126
- createParser(readerOptions: ReaderOptions) {
115
+ registerAndMakeDecoder(readerOptions: ReaderOptions) {
127
116
  const key = registerOption(readerOptions, {
128
117
  ...definition,
129
118
  valued: false,
130
119
  });
131
120
  return {
132
- parseValue() {
121
+ getAndDecodeValue() {
133
122
  const optionValues = readerOptions.getOptionValues(key);
134
123
  if (optionValues.length > 1) {
135
124
  throw new TypoError(
@@ -153,7 +142,13 @@ export function optionFlag(definition: {
153
142
  );
154
143
  }
155
144
  }
156
- return decodeValue(definition.long, label, typeBoolean, optionValue);
145
+ return decodeValue({
146
+ long: definition.long,
147
+ short: definition.short,
148
+ label,
149
+ type: typeBoolean,
150
+ input: optionValue,
151
+ });
157
152
  },
158
153
  };
159
154
  },
@@ -161,32 +156,22 @@ export function optionFlag(definition: {
161
156
  }
162
157
 
163
158
  /**
164
- * Creates an option that accepts exactly one value (e.g. `--output dist/` or
165
- * `--output=dist/`).
166
- *
167
- * **Parsing rules:**
168
- * - Absent → `definition.default()` is called. If the default factory throws, a
169
- * {@link TypoError} is produced.
170
- * - Specified once → the value is decoded with `definition.type`.
171
- * - Specified more than once → {@link TypoError} ("Requires a single value, but got
172
- * multiple").
159
+ * Creates an option that accepts exactly one value (e.g. `--output dist/`).
173
160
  *
174
- * **Value syntax:** `--long value`, `--long=value`, or (if `short` is set) `-s value`,
175
- * `-s=value`, or `-svalue`.
161
+ * Parsing: absent `default()`; once decoded with `type`; more than once → {@link TypoError}.
162
+ * Value syntax: `--long value`, `--long=value`, `-s value`, `-s=value`, `-svalue`.
176
163
  *
177
- * @typeParam Value - The TypeScript type produced by the type decoder.
164
+ * @typeParam Value - Type produced by the decoder.
178
165
  *
179
- * @param definition - Configuration for the option.
180
- * @param definition.long - Primary long-form name (without `--`). Must be lowercase.
181
- * @param definition.short - Optional short-form name (without `-`).
182
- * @param definition.description - Human-readable description for the help output.
183
- * @param definition.hint - Optional supplementary note shown in parentheses.
184
- * @param definition.aliases - Additional long/short names the parser also recognises.
185
- * @param definition.label - Custom label shown in the help output (e.g. `"FILE"`).
186
- * Defaults to the uppercased `type.content`.
187
- * @param definition.type - The {@link Type} used to decode the raw string value.
188
- * @param definition.default - Factory for the default value when the option is absent.
189
- * Throw an error from this factory to make the option effectively required.
166
+ * @param definition - Option configuration.
167
+ * @param definition.long - Long-form name (without `--`).
168
+ * @param definition.short - Short-form name (without `-`).
169
+ * @param definition.description - Help text.
170
+ * @param definition.hint - Short note shown in parentheses.
171
+ * @param definition.aliases - Additional names.
172
+ * @param definition.label - Value placeholder in help. Defaults to uppercased `type.content`.
173
+ * @param definition.type - Decoder for the raw string value.
174
+ * @param definition.default - Default when absent. Throw to make the option required.
190
175
  * @returns An {@link Option}`<Value>`.
191
176
  *
192
177
  * @example
@@ -222,13 +207,13 @@ export function optionSingleValue<Value>(definition: {
222
207
  label: label as Uppercase<string>,
223
208
  };
224
209
  },
225
- createParser(readerOptions: ReaderOptions) {
210
+ registerAndMakeDecoder(readerOptions: ReaderOptions) {
226
211
  const key = registerOption(readerOptions, {
227
212
  ...definition,
228
213
  valued: true,
229
214
  });
230
215
  return {
231
- parseValue() {
216
+ getAndDecodeValue() {
232
217
  const optionValues = readerOptions.getOptionValues(key);
233
218
  if (optionValues.length > 1) {
234
219
  throw new TypoError(
@@ -252,12 +237,13 @@ export function optionSingleValue<Value>(definition: {
252
237
  );
253
238
  }
254
239
  }
255
- return decodeValue(
256
- definition.long,
240
+ return decodeValue({
241
+ long: definition.long,
242
+ short: definition.short,
257
243
  label,
258
- definition.type,
259
- optionValue,
260
- );
244
+ type: definition.type,
245
+ input: optionValue,
246
+ });
261
247
  },
262
248
  };
263
249
  },
@@ -265,30 +251,21 @@ export function optionSingleValue<Value>(definition: {
265
251
  }
266
252
 
267
253
  /**
268
- * Creates an option that can be specified any number of times, collecting all provided
269
- * values into an array (e.g. `--file a.ts --file b.ts`).
270
- *
271
- * **Parsing rules:**
272
- * - Absent → empty array `[]`.
273
- * - Specified N times → array of N decoded values, in the order they appear on the
274
- * command line.
275
- * - Each occurrence is decoded independently with `definition.type`.
254
+ * Creates an option that collects every occurrence into an array (e.g. `--file a.ts --file b.ts`).
276
255
  *
277
- * **Value syntax:** `--long value`, `--long=value`, or (if `short` is set) `-s value`,
278
- * `-s=value`, or `-svalue`.
256
+ * Parsing: absent `[]`; N occurrences array of N decoded values in order.
257
+ * Value syntax: `--long value`, `--long=value`, `-s value`, `-s=value`, `-svalue`.
279
258
  *
280
- * @typeParam Value - The TypeScript type produced by the type decoder for each
281
- * occurrence.
259
+ * @typeParam Value - Type produced by the decoder for each occurrence.
282
260
  *
283
- * @param definition - Configuration for the option.
284
- * @param definition.long - Primary long-form name (without `--`). Must be lowercase.
285
- * @param definition.short - Optional short-form name (without `-`).
286
- * @param definition.description - Human-readable description for the help output.
287
- * @param definition.hint - Optional supplementary note shown in parentheses.
288
- * @param definition.aliases - Additional long/short names the parser also recognises.
289
- * @param definition.label - Custom label shown in the help output (e.g. `"FILE"`).
290
- * Defaults to the uppercased `type.content`.
291
- * @param definition.type - The {@link Type} used to decode each raw string value.
261
+ * @param definition - Option configuration.
262
+ * @param definition.long - Long-form name (without `--`).
263
+ * @param definition.short - Short-form name (without `-`).
264
+ * @param definition.description - Help text.
265
+ * @param definition.hint - Short note shown in parentheses.
266
+ * @param definition.aliases - Additional names.
267
+ * @param definition.label - Value placeholder in help. Defaults to uppercased `type.content`.
268
+ * @param definition.type - Decoder applied to each raw string value.
292
269
  * @returns An {@link Option}`<Array<Value>>`.
293
270
  *
294
271
  * @example
@@ -324,16 +301,22 @@ export function optionRepeatable<Value>(definition: {
324
301
  label: label as Uppercase<string>,
325
302
  };
326
303
  },
327
- createParser(readerOptions: ReaderOptions) {
304
+ registerAndMakeDecoder(readerOptions: ReaderOptions) {
328
305
  const key = registerOption(readerOptions, {
329
306
  ...definition,
330
307
  valued: true,
331
308
  });
332
309
  return {
333
- parseValue() {
310
+ getAndDecodeValue() {
334
311
  const optionValues = readerOptions.getOptionValues(key);
335
312
  return optionValues.map((optionValue) =>
336
- decodeValue(definition.long, label, definition.type, optionValue),
313
+ decodeValue({
314
+ long: definition.long,
315
+ short: definition.short,
316
+ label,
317
+ type: definition.type,
318
+ input: optionValue,
319
+ }),
337
320
  );
338
321
  },
339
322
  };
@@ -341,22 +324,28 @@ export function optionRepeatable<Value>(definition: {
341
324
  };
342
325
  }
343
326
 
344
- function decodeValue<Value>(
345
- long: string,
346
- label: string,
347
- type: Type<Value>,
348
- value: string,
349
- ): Value {
327
+ function decodeValue<Value>(params: {
328
+ long: string;
329
+ short: string | undefined;
330
+ label: string;
331
+ type: Type<Value>;
332
+ input: string;
333
+ }): Value {
350
334
  return TypoError.tryWithContext(
351
- () => type.decoder(value),
352
- () =>
353
- new TypoText(
354
- new TypoString(`--${long}`, typoStyleConstants),
355
- new TypoString(`: `),
356
- new TypoString(label, typoStyleUserInput),
357
- new TypoString(`: `),
358
- new TypoString(type.content, typoStyleLogic),
359
- ),
335
+ () => params.type.decoder(params.input),
336
+ () => {
337
+ const text = new TypoText();
338
+ if (params.short) {
339
+ text.pushString(new TypoString(`-${params.short}`, typoStyleConstants));
340
+ text.pushString(new TypoString(`, `));
341
+ }
342
+ text.pushString(new TypoString(`--${params.long}`, typoStyleConstants));
343
+ text.pushString(new TypoString(`: `));
344
+ text.pushString(new TypoString(params.label, typoStyleUserInput));
345
+ text.pushString(new TypoString(`: `));
346
+ text.pushString(new TypoString(params.type.content, typoStyleLogic));
347
+ return text;
348
+ },
360
349
  );
361
350
  }
362
351