@cli-forge/parser 0.6.0 → 0.8.0

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 (71) hide show
  1. package/package.json +1 -1
  2. package/src/index.d.ts +4 -1
  3. package/src/index.js +4 -1
  4. package/src/index.js.map +1 -1
  5. package/src/lib/option-types/array.d.ts +16 -0
  6. package/src/lib/option-types/array.js +3 -0
  7. package/src/lib/option-types/array.js.map +1 -0
  8. package/src/lib/option-types/boolean.d.ts +4 -0
  9. package/src/lib/option-types/boolean.js +3 -0
  10. package/src/lib/option-types/boolean.js.map +1 -0
  11. package/src/lib/option-types/common.d.ts +78 -0
  12. package/src/lib/option-types/common.js +3 -0
  13. package/src/lib/option-types/common.js.map +1 -0
  14. package/src/lib/option-types/index.d.ts +14 -0
  15. package/src/lib/option-types/index.js +11 -0
  16. package/src/lib/option-types/index.js.map +1 -0
  17. package/src/lib/option-types/number.d.ts +4 -0
  18. package/src/lib/option-types/number.js +3 -0
  19. package/src/lib/option-types/number.js.map +1 -0
  20. package/src/lib/option-types/object.d.ts +10 -0
  21. package/src/lib/option-types/object.js +3 -0
  22. package/src/lib/option-types/object.js.map +1 -0
  23. package/src/lib/option-types/option-config-to-type.d.ts +20 -0
  24. package/src/lib/option-types/option-config-to-type.js +3 -0
  25. package/src/lib/option-types/option-config-to-type.js.map +1 -0
  26. package/src/lib/option-types/option-config.d.ts +15 -0
  27. package/src/lib/option-types/option-config.js +3 -0
  28. package/src/lib/option-types/option-config.js.map +1 -0
  29. package/src/lib/option-types/string.d.ts +4 -0
  30. package/src/lib/option-types/string.js +3 -0
  31. package/src/lib/option-types/string.js.map +1 -0
  32. package/src/lib/parser.d.ts +8 -109
  33. package/src/lib/parser.js +41 -157
  34. package/src/lib/parser.js.map +1 -1
  35. package/src/lib/parsers/array.d.ts +3 -0
  36. package/src/lib/parsers/array.js +60 -0
  37. package/src/lib/parsers/array.js.map +1 -0
  38. package/src/lib/parsers/boolean.d.ts +3 -0
  39. package/src/lib/parsers/boolean.js +24 -0
  40. package/src/lib/parsers/boolean.js.map +1 -0
  41. package/src/lib/parsers/number.d.ts +3 -0
  42. package/src/lib/parsers/number.js +18 -0
  43. package/src/lib/parsers/number.js.map +1 -0
  44. package/src/lib/parsers/object.d.ts +3 -0
  45. package/src/lib/parsers/object.js +83 -0
  46. package/src/lib/parsers/object.js.map +1 -0
  47. package/src/lib/parsers/parser-map.d.ts +2 -0
  48. package/src/lib/parsers/parser-map.js +16 -0
  49. package/src/lib/parsers/parser-map.js.map +1 -0
  50. package/src/lib/parsers/string.d.ts +3 -0
  51. package/src/lib/parsers/string.js +18 -0
  52. package/src/lib/parsers/string.js.map +1 -0
  53. package/src/lib/parsers/typings.d.ts +11 -0
  54. package/src/lib/parsers/typings.js +10 -0
  55. package/src/lib/parsers/typings.js.map +1 -0
  56. package/src/lib/{utils.js → utils/case-transformations.js} +1 -1
  57. package/src/lib/utils/case-transformations.js.map +1 -0
  58. package/src/lib/utils/chain.d.ts +316 -0
  59. package/src/lib/utils/chain.js +54 -0
  60. package/src/lib/utils/chain.js.map +1 -0
  61. package/src/lib/utils/flags.d.ts +3 -0
  62. package/src/lib/utils/flags.js +28 -0
  63. package/src/lib/utils/flags.js.map +1 -0
  64. package/src/lib/utils/get-configured-key.d.ts +3 -0
  65. package/src/lib/utils/get-configured-key.js +40 -0
  66. package/src/lib/utils/get-configured-key.js.map +1 -0
  67. package/src/lib/utils/read-default-value.d.ts +2 -0
  68. package/src/lib/utils/read-default-value.js +23 -0
  69. package/src/lib/utils/read-default-value.js.map +1 -0
  70. package/src/lib/utils.js.map +0 -1
  71. /package/src/lib/{utils.d.ts → utils/case-transformations.d.ts} +0 -0
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NoValueError = void 0;
4
+ class NoValueError extends Error {
5
+ constructor() {
6
+ super('Expected a value');
7
+ }
8
+ }
9
+ exports.NoValueError = NoValueError;
10
+ //# sourceMappingURL=typings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typings.js","sourceRoot":"","sources":["../../../../../../packages/parser/src/lib/parsers/typings.ts"],"names":[],"mappings":";;;AAWA,MAAa,YAAa,SAAQ,KAAK;IACrC;QACE,KAAK,CAAC,kBAAkB,CAAC,CAAC;IAC5B,CAAC;CACF;AAJD,oCAIC"}
@@ -43,4 +43,4 @@ function getEnvKey(prefix, key) {
43
43
  ? `${prefix}_${fromCamelOrDashedCaseToConstCase(key)}`
44
44
  : fromCamelOrDashedCaseToConstCase(key);
45
45
  }
46
- //# sourceMappingURL=utils.js.map
46
+ //# sourceMappingURL=case-transformations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"case-transformations.js","sourceRoot":"","sources":["../../../../../../packages/parser/src/lib/utils/case-transformations.ts"],"names":[],"mappings":";;AAAA,sDAEC;AAED,4EA+BC;AAED,8BAIC;AAzCD,SAAgB,qBAAqB,CAAC,GAAW;IAC/C,OAAO,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;AAC3E,CAAC;AAED,SAAgB,gCAAgC,CAAC,GAAW;IAC1D,MAAM,KAAK,GAAG,EAAE,CAAC;IACjB,IAAI,WAAW,GAAG,EAAE,CAAC;IACrB,IAAI,IAAwB,CAAC;IAC7B,KAAK,MAAM,IAAI,IAAI,GAAG,EAAE,CAAC;QACvB,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;YACjB,IAAI,WAAW,CAAC,MAAM,EAAE,CAAC;gBACvB,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YAC1B,CAAC;YACD,WAAW,GAAG,EAAE,CAAC;YACjB,SAAS;QACX,CAAC;QACD,oDAAoD;QACpD,IAAI,IAAI,IAAI,IAAI,EAAE,WAAW,EAAE,KAAK,IAAI,IAAI,IAAI,KAAK,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;YACxE,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YACxB,WAAW,GAAG,IAAI,CAAC;YACnB,sCAAsC;QACxC,CAAC;aAAM,IACL,IAAI,EAAE,WAAW,EAAE,KAAK,IAAI;YAC5B,IAAI,KAAK,IAAI,CAAC,WAAW,EAAE;YAC3B,WAAW,CAAC,MAAM,GAAG,CAAC,EACtB,CAAC;YACD,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;YACrC,WAAW,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;QAC7C,CAAC;aAAM,CAAC;YACN,WAAW,IAAI,IAAI,CAAC;QACtB,CAAC;QACD,IAAI,GAAG,IAAI,CAAC;IACd,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACxB,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;AACvC,CAAC;AAED,SAAgB,SAAS,CAAC,MAA0B,EAAE,GAAW;IAC/D,OAAO,MAAM;QACX,CAAC,CAAC,GAAG,MAAM,IAAI,gCAAgC,CAAC,GAAG,CAAC,EAAE;QACtD,CAAC,CAAC,gCAAgC,CAAC,GAAG,CAAC,CAAC;AAC5C,CAAC"}
@@ -0,0 +1,316 @@
1
+ import { OptionConfig } from '../option-types';
2
+ import { ArgvParser, ParsedArgs } from '../parser';
3
+ type UnaryFunction<T, R> = (arg: T) => R;
4
+ /**
5
+ * Applies a series of functions to an initial value, passing the result of each function to the next.
6
+ *
7
+ * Used to convert code that looks like:
8
+ * ```typescript
9
+ * const a = addB(addC({ a: 'a' }));
10
+ * ```
11
+ * to:
12
+ * ```typescript
13
+ * const a = chain({ a: 'a' }, addB, addC);
14
+ * ```
15
+ *
16
+ * See [composable-options](/examples/composable-options) for an example of how this can be used.
17
+ *
18
+ * @param initial Initial value to pass through the chain
19
+ * @param fns Functions to apply to the initial value, and each subsequent value
20
+ * @returns Updated value after all functions have been applied
21
+ */
22
+ export declare function chain<T0, R>(initial: T0, fn0: UnaryFunction<T0, R>): R;
23
+ /**
24
+ * Applies a series of functions to an initial value, passing the result of each function to the next.
25
+ *
26
+ * Used to convert code that looks like:
27
+ * ```typescript
28
+ * const a = addB(addC({ a: 'a' }));
29
+ * ```
30
+ * to:
31
+ * ```typescript
32
+ * const a = chain({ a: 'a' }, addB, addC);
33
+ * ```
34
+ *
35
+ * See [composable-options](/examples/composable-options) for an example of how this can be used.
36
+ *
37
+ * @param initial Initial value to pass through the chain
38
+ * @param fns Functions to apply to the initial value, and each subsequent value
39
+ * @returns Updated value after all functions have been applied
40
+ */
41
+ export declare function chain<T0, T1, R>(initial: T0, fn0: UnaryFunction<T0, T1>, fn1: UnaryFunction<T1, R>): R;
42
+ /**
43
+ * Applies a series of functions to an initial value, passing the result of each function to the next.
44
+ *
45
+ * Used to convert code that looks like:
46
+ * ```typescript
47
+ * const a = addB(addC({ a: 'a' }));
48
+ * ```
49
+ * to:
50
+ * ```typescript
51
+ * const a = chain({ a: 'a' }, addB, addC);
52
+ * ```
53
+ *
54
+ * See [composable-options](/examples/composable-options) for an example of how this can be used.
55
+ *
56
+ * @param initial Initial value to pass through the chain
57
+ * @param fns Functions to apply to the initial value, and each subsequent value
58
+ * @returns Updated value after all functions have been applied
59
+ */
60
+ export declare function chain<T0, T1, T2, R>(initial: T0, fn0: UnaryFunction<T0, T1>, fn1: UnaryFunction<T1, T2>, fn2: UnaryFunction<T2, R>): R;
61
+ /**
62
+ * Applies a series of functions to an initial value, passing the result of each function to the next.
63
+ *
64
+ * Used to convert code that looks like:
65
+ * ```typescript
66
+ * const a = addB(addC({ a: 'a' }));
67
+ * ```
68
+ * to:
69
+ * ```typescript
70
+ * const a = chain({ a: 'a' }, addB, addC);
71
+ * ```
72
+ *
73
+ * See [composable-options](/examples/composable-options) for an example of how this can be used.
74
+ *
75
+ * @param initial Initial value to pass through the chain
76
+ * @param fns Functions to apply to the initial value, and each subsequent value
77
+ * @returns Updated value after all functions have been applied
78
+ */
79
+ export declare function chain<T0, T1, T2, T3, R>(initial: T0, fn0: UnaryFunction<T0, T1>, fn1: UnaryFunction<T1, T2>, fn2: UnaryFunction<T2, T3>, fn3: UnaryFunction<T3, R>): R;
80
+ /**
81
+ * Applies a series of functions to an initial value, passing the result of each function to the next.
82
+ *
83
+ * Used to convert code that looks like:
84
+ * ```typescript
85
+ * const a = addB(addC({ a: 'a' }));
86
+ * ```
87
+ * to:
88
+ * ```typescript
89
+ * const a = chain({ a: 'a' }, addB, addC);
90
+ * ```
91
+ *
92
+ * See [composable-options](/examples/composable-options) for an example of how this can be used.
93
+ *
94
+ * @param initial Initial value to pass through the chain
95
+ * @param fns Functions to apply to the initial value, and each subsequent value
96
+ * @returns Updated value after all functions have been applied
97
+ */
98
+ export declare function chain<T0, T1, T2, T3, T4, R>(initial: T0, fn0: UnaryFunction<T0, T1>, fn1: UnaryFunction<T1, T2>, fn2: UnaryFunction<T2, T3>, fn3: UnaryFunction<T3, T4>, fn4: UnaryFunction<T4, R>): R;
99
+ /**
100
+ * Applies a series of functions to an initial value, passing the result of each function to the next.
101
+ *
102
+ * Used to convert code that looks like:
103
+ * ```typescript
104
+ * const a = addB(addC({ a: 'a' }));
105
+ * ```
106
+ * to:
107
+ * ```typescript
108
+ * const a = chain({ a: 'a' }, addB, addC);
109
+ * ```
110
+ *
111
+ * See [composable-options](/examples/composable-options) for an example of how this can be used.
112
+ *
113
+ * @param initial Initial value to pass through the chain
114
+ * @param fns Functions to apply to the initial value, and each subsequent value
115
+ * @returns Updated value after all functions have been applied
116
+ */
117
+ export declare function chain<T0, T1, T2, T3, T4, T5, R>(initial: T0, fn0: UnaryFunction<T0, T1>, fn1: UnaryFunction<T1, T2>, fn2: UnaryFunction<T2, T3>, fn3: UnaryFunction<T3, T4>, fn4: UnaryFunction<T4, T5>, fn5: UnaryFunction<T5, R>): R;
118
+ /**
119
+ * Applies a series of functions to an initial value, passing the result of each function to the next.
120
+ *
121
+ * Used to convert code that looks like:
122
+ * ```typescript
123
+ * const a = addB(addC({ a: 'a' }));
124
+ * ```
125
+ * to:
126
+ * ```typescript
127
+ * const a = chain({ a: 'a' }, addB, addC);
128
+ * ```
129
+ *
130
+ * See [composable-options](/examples/composable-options) for an example of how this can be used.
131
+ *
132
+ * @param initial Initial value to pass through the chain
133
+ * @param fns Functions to apply to the initial value, and each subsequent value
134
+ * @returns Updated value after all functions have been applied
135
+ */
136
+ export declare function chain<T0, T1, T2, T3, T4, T5, T6, R>(initial: T0, fn0: UnaryFunction<T0, T1>, fn1: UnaryFunction<T1, T2>, fn2: UnaryFunction<T2, T3>, fn3: UnaryFunction<T3, T4>, fn4: UnaryFunction<T4, T5>, fn5: UnaryFunction<T5, T6>, fn6: UnaryFunction<T6, R>): R;
137
+ /**
138
+ * Applies a series of functions to an initial value, passing the result of each function to the next.
139
+ *
140
+ * Used to convert code that looks like:
141
+ * ```typescript
142
+ * const a = addB(addC({ a: 'a' }));
143
+ * ```
144
+ * to:
145
+ * ```typescript
146
+ * const a = chain({ a: 'a' }, addB, addC);
147
+ * ```
148
+ *
149
+ * See [composable-options](/examples/composable-options) for an example of how this can be used.
150
+ *
151
+ * @param initial Initial value to pass through the chain
152
+ * @param fns Functions to apply to the initial value, and each subsequent value
153
+ * @returns Updated value after all functions have been applied
154
+ */
155
+ export declare function chain<T0, T1, T2, T3, T4, T5, T6, T7, R>(initial: T0, fn0: UnaryFunction<T0, T1>, fn1: UnaryFunction<T1, T2>, fn2: UnaryFunction<T2, T3>, fn3: UnaryFunction<T3, T4>, fn4: UnaryFunction<T4, T5>, fn5: UnaryFunction<T5, T6>, fn6: UnaryFunction<T6, T7>, fn7: UnaryFunction<T7, R>): R;
156
+ /**
157
+ * Applies a series of functions to an initial value, passing the result of each function to the next.
158
+ *
159
+ * Used to convert code that looks like:
160
+ * ```typescript
161
+ * const a = addB(addC({ a: 'a' }));
162
+ * ```
163
+ * to:
164
+ * ```typescript
165
+ * const a = chain({ a: 'a' }, addB, addC);
166
+ * ```
167
+ *
168
+ * See [composable-options](/examples/composable-options) for an example of how this can be used.
169
+ *
170
+ * @param initial Initial value to pass through the chain
171
+ * @param fns Functions to apply to the initial value, and each subsequent value
172
+ * @returns Updated value after all functions have been applied
173
+ */
174
+ export declare function chain<T0, T1, T2, T3, T4, T5, T6, T7, T8, R>(initial: T0, fn0: UnaryFunction<T0, T1>, fn1: UnaryFunction<T1, T2>, fn2: UnaryFunction<T2, T3>, fn3: UnaryFunction<T3, T4>, fn4: UnaryFunction<T4, T5>, fn5: UnaryFunction<T5, T6>, fn6: UnaryFunction<T6, T7>, fn7: UnaryFunction<T7, T8>, fn8: UnaryFunction<T8, R>): R;
175
+ /**
176
+ * Applies a series of functions to an initial value, passing the result of each function to the next.
177
+ *
178
+ * Used to convert code that looks like:
179
+ * ```typescript
180
+ * const a = addB(addC({ a: 'a' }));
181
+ * ```
182
+ * to:
183
+ * ```typescript
184
+ * const a = chain({ a: 'a' }, addB, addC);
185
+ * ```
186
+ *
187
+ * See [composable-options](/examples/composable-options) for an example of how this can be used.
188
+ *
189
+ * @param initial Initial value to pass through the chain
190
+ * @param fns Functions to apply to the initial value, and each subsequent value
191
+ * @returns Updated value after all functions have been applied
192
+ */
193
+ export declare function chain<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, R>(initial: T0, fn0: UnaryFunction<T0, T1>, fn1: UnaryFunction<T1, T2>, fn2: UnaryFunction<T2, T3>, fn3: UnaryFunction<T3, T4>, fn4: UnaryFunction<T4, T5>, fn5: UnaryFunction<T5, T6>, fn6: UnaryFunction<T6, T7>, fn7: UnaryFunction<T7, T8>, fn8: UnaryFunction<T8, T9>, fn9: UnaryFunction<T9, R>): R;
194
+ /**
195
+ * Applies a series of functions to an initial value, passing the result of each function to the next.
196
+ *
197
+ * Used to convert code that looks like:
198
+ * ```typescript
199
+ * const a = addB(addC({ a: 'a' }));
200
+ * ```
201
+ * to:
202
+ * ```typescript
203
+ * const a = chain({ a: 'a' }, addB, addC);
204
+ * ```
205
+ *
206
+ * See [composable-options](/examples/composable-options) for an example of how this can be used.
207
+ *
208
+ * @param initial Initial value to pass through the chain
209
+ * @param fns Functions to apply to the initial value, and each subsequent value
210
+ * @returns Updated value after all functions have been applied
211
+ */
212
+ export declare function chain<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, R>(initial: T0, fn0: UnaryFunction<T0, T1>, fn1: UnaryFunction<T1, T2>, fn2: UnaryFunction<T2, T3>, fn3: UnaryFunction<T3, T4>, fn4: UnaryFunction<T4, T5>, fn5: UnaryFunction<T5, T6>, fn6: UnaryFunction<T6, T7>, fn7: UnaryFunction<T7, T8>, fn8: UnaryFunction<T8, T9>, fn9: UnaryFunction<T9, T10>, fn10: UnaryFunction<T10, R>): R;
213
+ /**
214
+ * Applies a series of functions to an initial value, passing the result of each function to the next.
215
+ *
216
+ * Used to convert code that looks like:
217
+ * ```typescript
218
+ * const a = addB(addC({ a: 'a' }));
219
+ * ```
220
+ * to:
221
+ * ```typescript
222
+ * const a = chain({ a: 'a' }, addB, addC);
223
+ * ```
224
+ *
225
+ * See [composable-options](/examples/composable-options) for an example of how this can be used.
226
+ *
227
+ * @param initial Initial value to pass through the chain
228
+ * @param fns Functions to apply to the initial value, and each subsequent value
229
+ * @returns Updated value after all functions have been applied
230
+ */
231
+ export declare function chain<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, R>(initial: T0, fn0: UnaryFunction<T0, T1>, fn1: UnaryFunction<T1, T2>, fn2: UnaryFunction<T2, T3>, fn3: UnaryFunction<T3, T4>, fn4: UnaryFunction<T4, T5>, fn5: UnaryFunction<T5, T6>, fn6: UnaryFunction<T6, T7>, fn7: UnaryFunction<T7, T8>, fn8: UnaryFunction<T8, T9>, fn9: UnaryFunction<T9, T10>, fn10: UnaryFunction<T10, T11>, fn11: UnaryFunction<T11, R>): R;
232
+ /**
233
+ * Applies a series of functions to an initial value, passing the result of each function to the next.
234
+ *
235
+ * Used to convert code that looks like:
236
+ * ```typescript
237
+ * const a = addB(addC({ a: 'a' }));
238
+ * ```
239
+ * to:
240
+ * ```typescript
241
+ * const a = chain({ a: 'a' }, addB, addC);
242
+ * ```
243
+ *
244
+ * See [composable-options](/examples/composable-options) for an example of how this can be used.
245
+ *
246
+ * @param initial Initial value to pass through the chain
247
+ * @param fns Functions to apply to the initial value, and each subsequent value
248
+ * @returns Updated value after all functions have been applied
249
+ */
250
+ export declare function chain<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, R>(initial: T0, fn0: UnaryFunction<T0, T1>, fn1: UnaryFunction<T1, T2>, fn2: UnaryFunction<T2, T3>, fn3: UnaryFunction<T3, T4>, fn4: UnaryFunction<T4, T5>, fn5: UnaryFunction<T5, T6>, fn6: UnaryFunction<T6, T7>, fn7: UnaryFunction<T7, T8>, fn8: UnaryFunction<T8, T9>, fn9: UnaryFunction<T9, T10>, fn10: UnaryFunction<T10, T11>, fn11: UnaryFunction<T11, T12>, fn12: UnaryFunction<T12, R>): R;
251
+ /**
252
+ * Applies a series of functions to an initial value, passing the result of each function to the next.
253
+ *
254
+ * Used to convert code that looks like:
255
+ * ```typescript
256
+ * const a = addB(addC({ a: 'a' }));
257
+ * ```
258
+ * to:
259
+ * ```typescript
260
+ * const a = chain({ a: 'a' }, addB, addC);
261
+ * ```
262
+ *
263
+ * See [composable-options](/examples/composable-options) for an example of how this can be used.
264
+ *
265
+ * @param initial Initial value to pass through the chain
266
+ * @param fns Functions to apply to the initial value, and each subsequent value
267
+ * @returns Updated value after all functions have been applied
268
+ */
269
+ export declare function chain<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, R>(initial: T0, fn0: UnaryFunction<T0, T1>, fn1: UnaryFunction<T1, T2>, fn2: UnaryFunction<T2, T3>, fn3: UnaryFunction<T3, T4>, fn4: UnaryFunction<T4, T5>, fn5: UnaryFunction<T5, T6>, fn6: UnaryFunction<T6, T7>, fn7: UnaryFunction<T7, T8>, fn8: UnaryFunction<T8, T9>, fn9: UnaryFunction<T9, T10>, fn10: UnaryFunction<T10, T11>, fn11: UnaryFunction<T11, T12>, fn12: UnaryFunction<T12, T13>, fn13: UnaryFunction<T13, R>): R;
270
+ /**
271
+ * Applies a series of functions to an initial value, passing the result of each function to the next.
272
+ *
273
+ * Used to convert code that looks like:
274
+ * ```typescript
275
+ * const a = addB(addC({ a: 'a' }));
276
+ * ```
277
+ * to:
278
+ * ```typescript
279
+ * const a = chain({ a: 'a' }, addB, addC);
280
+ * ```
281
+ *
282
+ * See [composable-options](/examples/composable-options) for an example of how this can be used.
283
+ *
284
+ * @param initial Initial value to pass through the chain
285
+ * @param fns Functions to apply to the initial value, and each subsequent value
286
+ * @returns Updated value after all functions have been applied
287
+ */
288
+ export declare function chain<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, R>(initial: T0, fn0: UnaryFunction<T0, T1>, fn1: UnaryFunction<T1, T2>, fn2: UnaryFunction<T2, T3>, fn3: UnaryFunction<T3, T4>, fn4: UnaryFunction<T4, T5>, fn5: UnaryFunction<T5, T6>, fn6: UnaryFunction<T6, T7>, fn7: UnaryFunction<T7, T8>, fn8: UnaryFunction<T8, T9>, fn9: UnaryFunction<T9, T10>, fn10: UnaryFunction<T10, T11>, fn11: UnaryFunction<T11, T12>, fn12: UnaryFunction<T12, T13>, fn13: UnaryFunction<T13, T14>, fn14: UnaryFunction<T14, R>): R;
289
+ /**
290
+ * Applies a series of functions to an initial value, passing the result of each function to the next.
291
+ *
292
+ * Used to convert code that looks like:
293
+ * ```typescript
294
+ * const a = addB(addC({ a: 'a' }));
295
+ * ```
296
+ * to:
297
+ * ```typescript
298
+ * const a = chain({ a: 'a' }, addB, addC);
299
+ * ```
300
+ *
301
+ * See [composable-options](/examples/composable-options) for an example of how this can be used.
302
+ *
303
+ * @param initial Initial value to pass through the chain
304
+ * @param fns Functions to apply to the initial value, and each subsequent value
305
+ * @returns Updated value after all functions have been applied
306
+ */
307
+ export declare function chain<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, R>(initial: T0, fn0: UnaryFunction<T0, T1>, fn1: UnaryFunction<T1, T2>, fn2: UnaryFunction<T2, T3>, fn3: UnaryFunction<T3, T4>, fn4: UnaryFunction<T4, T5>, fn5: UnaryFunction<T5, T6>, fn6: UnaryFunction<T6, T7>, fn7: UnaryFunction<T7, T8>, fn8: UnaryFunction<T8, T9>, fn9: UnaryFunction<T9, T10>, fn10: UnaryFunction<T10, T11>, fn11: UnaryFunction<T11, T12>, fn12: UnaryFunction<T12, T13>, fn13: UnaryFunction<T13, T14>, fn14: UnaryFunction<T14, T15>, fn15: UnaryFunction<T15, R>): R;
308
+ /**
309
+ * A composition helper to be used with {@link chain}.
310
+ *
311
+ * @param name The name of the option to add
312
+ * @param config The configuration for the option
313
+ * @returns A unary function that adds an option to an {@link ArgvParser}.
314
+ */
315
+ export declare function makeComposableOption<const TKey extends string, const TOptionConfig extends OptionConfig>(name: TKey, config: TOptionConfig): <const T extends ParsedArgs>(argv: ArgvParser<T>) => ArgvParser<T & { [key in TKey]: import("../option-types").OptionConfigToType<TOptionConfig>; }>;
316
+ export {};
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ // This file pains me quite a bit. Before any feedback is given, consider the following:
3
+ // - There is currently no way to infer the types of a `...rest` parameter individually.
4
+ // - This is how rxjs does it, and that's because its really the only way in current TS / JS
5
+ // - See: https://github.com/ReactiveX/rxjs/blob/master/packages%2Fobservable%2Fsrc%2Fobservable.ts#L788
6
+ // - This isn't maintained or even written by hand, aside from the final implementation. The various
7
+ // overload signatures are copilot generated.
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.chain = chain;
10
+ exports.makeComposableOption = makeComposableOption;
11
+ /**
12
+ * Applies a series of functions to an initial value, passing the result of each function to the next.
13
+ *
14
+ * Used to convert code that looks like:
15
+ * ```typescript
16
+ * const a = addB(addC({ a: 'a' }));
17
+ * ```
18
+ * to:
19
+ * ```typescript
20
+ * const a = chain({ a: 'a' }, addB, addC);
21
+ * ```
22
+ *
23
+ * See [composable-options](/examples/composable-options) for an example of how this can be used.
24
+ *
25
+ * NOTE: Seeing a return type of `unknown`? This is likely due to the number of functions passed to
26
+ * `chain` exceeding the number of overloads provided. There is a technical limitation in TypeScript
27
+ * that means we need to provide a finite number of overloads. While we anticipate that 16 overloads
28
+ * should be enough for most use cases, if you need more you can combine chains together like below:
29
+ * ```typescript
30
+ * const a = chain(
31
+ * { a: 'a' },
32
+ * addB,
33
+ * (iv) => chain(iv, addC, addD, addE),
34
+ * );
35
+ * ```
36
+ *
37
+ * @param initial Initial value to pass through the chain
38
+ * @param fns Functions to apply to the initial value, and each subsequent value
39
+ * @returns Updated value after all functions have been applied
40
+ */
41
+ function chain(initial, ...fns) {
42
+ return fns.reduce((acc, fn) => fn(acc), initial);
43
+ }
44
+ /**
45
+ * A composition helper to be used with {@link chain}.
46
+ *
47
+ * @param name The name of the option to add
48
+ * @param config The configuration for the option
49
+ * @returns A unary function that adds an option to an {@link ArgvParser}.
50
+ */
51
+ function makeComposableOption(name, config) {
52
+ return (argv) => argv.option(name, config);
53
+ }
54
+ //# sourceMappingURL=chain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chain.js","sourceRoot":"","sources":["../../../../../../packages/parser/src/lib/utils/chain.ts"],"names":[],"mappings":";AAAA,wFAAwF;AACxF,wFAAwF;AACxF,4FAA4F;AAC5F,0GAA0G;AAC1G,oGAAoG;AACpG,+CAA+C;;AA6jB/C,sBAKC;AASD,oDAMC;AAlDD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,SAAgB,KAAK,CACnB,OAAW,EACX,GAAG,GAA8B;IAEjC,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC;AACnD,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,oBAAoB,CAGlC,IAAU,EAAE,MAAqB;IACjC,OAAO,CAA6B,IAAmB,EAAE,EAAE,CACzD,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare function isFlag(str: string): str is `-${string}`;
2
+ export declare function readArgKeys(str: `-${string}`): string[];
3
+ export declare function isNextFlag(str: string): boolean;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isFlag = isFlag;
4
+ exports.readArgKeys = readArgKeys;
5
+ exports.isNextFlag = isNextFlag;
6
+ const case_transformations_1 = require("./case-transformations");
7
+ function isFlag(str) {
8
+ return str.startsWith('-');
9
+ }
10
+ function readArgKeys(str) {
11
+ // Long flags (e.g. --foo)
12
+ if (str.startsWith('--')) {
13
+ const key = str.slice(2);
14
+ if (key.includes('-')) {
15
+ return [(0, case_transformations_1.fromDashedToCamelCase)(key)];
16
+ }
17
+ return [str.slice(2)];
18
+ // Short flag combinations (e.g. -xvf)
19
+ }
20
+ else if (str.startsWith('-')) {
21
+ return str.slice(1).split('');
22
+ }
23
+ throw new Error(`Invalid flag ${str}`);
24
+ }
25
+ function isNextFlag(str) {
26
+ return str.startsWith('--') || str.startsWith('-');
27
+ }
28
+ //# sourceMappingURL=flags.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flags.js","sourceRoot":"","sources":["../../../../../../packages/parser/src/lib/utils/flags.ts"],"names":[],"mappings":";;AAEA,wBAEC;AACD,kCAaC;AACD,gCAEC;AArBD,iEAA+D;AAE/D,SAAgB,MAAM,CAAC,GAAW;IAChC,OAAO,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AAC7B,CAAC;AACD,SAAgB,WAAW,CAAC,GAAiB;IAC3C,0BAA0B;IAC1B,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACzB,MAAM,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACzB,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACtB,OAAO,CAAC,IAAA,4CAAqB,EAAC,GAAG,CAAC,CAAC,CAAC;QACtC,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACtB,sCAAsC;IACxC,CAAC;SAAM,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/B,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAChC,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,gBAAgB,GAAG,EAAE,CAAC,CAAC;AACzC,CAAC;AACD,SAAgB,UAAU,CAAC,GAAW;IACpC,OAAO,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AACrD,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { OptionConfig } from '../option-types';
2
+ import { ParsedArgs } from '../parser';
3
+ export declare function getConfiguredOptionKey<T extends ParsedArgs>(key: string, configuredOptions: Partial<Record<keyof T, OptionConfig>>): keyof T | undefined;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getConfiguredOptionKey = getConfiguredOptionKey;
4
+ function getConfiguredOptionKey(key, configuredOptions) {
5
+ if (key in configuredOptions) {
6
+ return key;
7
+ }
8
+ function normalizeNegatedBooleanKey(key) {
9
+ if (key.startsWith('no') &&
10
+ key.length > 2 &&
11
+ key[2] === key[2].toUpperCase()) {
12
+ const stripped = key.slice(2);
13
+ return [stripped[0].toLowerCase(), stripped.slice(1)].join('');
14
+ }
15
+ return key;
16
+ }
17
+ function normalizeObjectOptionKey(key) {
18
+ if (key.includes('.')) {
19
+ return key.split('.')[0];
20
+ }
21
+ return key;
22
+ }
23
+ // Handles booleans passed as `--no-foo`
24
+ const normalizedKey = normalizeObjectOptionKey(normalizeNegatedBooleanKey(key));
25
+ if (normalizedKey in configuredOptions) {
26
+ return normalizedKey;
27
+ }
28
+ for (const configuredKey in configuredOptions) {
29
+ const config = configuredOptions[configuredKey];
30
+ if (config?.alias?.includes(key)) {
31
+ return configuredKey;
32
+ }
33
+ // Handles negated booleans that are aliased
34
+ if (config?.type === 'boolean' && config.alias?.includes(normalizedKey)) {
35
+ return configuredKey;
36
+ }
37
+ }
38
+ return undefined;
39
+ }
40
+ //# sourceMappingURL=get-configured-key.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-configured-key.js","sourceRoot":"","sources":["../../../../../../packages/parser/src/lib/utils/get-configured-key.ts"],"names":[],"mappings":";;AAGA,wDA+CC;AA/CD,SAAgB,sBAAsB,CACpC,GAAW,EACX,iBAAyD;IAEzD,IAAI,GAAG,IAAI,iBAAiB,EAAE,CAAC;QAC7B,OAAO,GAAc,CAAC;IACxB,CAAC;IAED,SAAS,0BAA0B,CAAC,GAAW;QAC7C,IACE,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC;YACpB,GAAG,CAAC,MAAM,GAAG,CAAC;YACd,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,EAC/B,CAAC;YACD,MAAM,QAAQ,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAC9B,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACjE,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IAED,SAAS,wBAAwB,CAAC,GAAW;QAC3C,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACtB,OAAO,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3B,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IAED,wCAAwC;IACxC,MAAM,aAAa,GAAG,wBAAwB,CAC5C,0BAA0B,CAAC,GAAG,CAAC,CAChC,CAAC;IAEF,IAAI,aAAa,IAAI,iBAAiB,EAAE,CAAC;QACvC,OAAO,aAAwB,CAAC;IAClC,CAAC;IAED,KAAK,MAAM,aAAa,IAAI,iBAAiB,EAAE,CAAC;QAC9C,MAAM,MAAM,GAAG,iBAAiB,CAAC,aAAa,CAAC,CAAC;QAChD,IAAI,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACjC,OAAO,aAAwB,CAAC;QAClC,CAAC;QACD,4CAA4C;QAC5C,IAAI,MAAM,EAAE,IAAI,KAAK,SAAS,IAAI,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC;YACxE,OAAO,aAAwB,CAAC;QAClC,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { OptionConfig, OptionConfigToType } from '../option-types';
2
+ export declare function readDefaultValue<const T extends OptionConfig>(option: T): [OptionConfigToType<T> | undefined, string | undefined];
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readDefaultValue = readDefaultValue;
4
+ function readDefaultValue(option) {
5
+ if (option.default !== undefined) {
6
+ const declaredDefault = option.default;
7
+ if (typeof declaredDefault === 'object') {
8
+ if ('value' in declaredDefault) {
9
+ const value = declaredDefault.value;
10
+ return [value, declaredDefault.description];
11
+ }
12
+ if ('factory' in declaredDefault) {
13
+ const factory = declaredDefault.factory;
14
+ return [factory(), declaredDefault.description];
15
+ }
16
+ }
17
+ else {
18
+ return [declaredDefault, undefined];
19
+ }
20
+ }
21
+ return [undefined, undefined];
22
+ }
23
+ //# sourceMappingURL=read-default-value.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-default-value.js","sourceRoot":"","sources":["../../../../../../packages/parser/src/lib/utils/read-default-value.ts"],"names":[],"mappings":";;AAOA,4CAoBC;AApBD,SAAgB,gBAAgB,CAC9B,MAAS;IAET,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QACjC,MAAM,eAAe,GAAG,MAAM,CAAC,OAA4B,CAAC;QAC5D,IAAI,OAAO,eAAe,KAAK,QAAQ,EAAE,CAAC;YACxC,IAAI,OAAO,IAAI,eAAe,EAAE,CAAC;gBAC/B,MAAM,KAAK,GAAG,eAAe,CAAC,KAAqC,CAAC;gBACpE,OAAO,CAAC,KAAK,EAAE,eAAe,CAAC,WAAW,CAAC,CAAC;YAC9C,CAAC;YACD,IAAI,SAAS,IAAI,eAAe,EAAE,CAAC;gBACjC,MAAM,OAAO,GACX,eAAe,CAAC,OAA6C,CAAC;gBAChE,OAAO,CAAC,OAAO,EAAE,EAAE,eAAe,CAAC,WAAW,CAAC,CAAC;YAClD,CAAC;QACH,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IACD,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;AAChC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../packages/parser/src/lib/utils.ts"],"names":[],"mappings":";;AAAA,sDAEC;AAED,4EA+BC;AAED,8BAIC;AAzCD,SAAgB,qBAAqB,CAAC,GAAW;IAC/C,OAAO,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;AAC3E,CAAC;AAED,SAAgB,gCAAgC,CAAC,GAAW;IAC1D,MAAM,KAAK,GAAG,EAAE,CAAC;IACjB,IAAI,WAAW,GAAG,EAAE,CAAC;IACrB,IAAI,IAAwB,CAAC;IAC7B,KAAK,MAAM,IAAI,IAAI,GAAG,EAAE,CAAC;QACvB,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;YACjB,IAAI,WAAW,CAAC,MAAM,EAAE,CAAC;gBACvB,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YAC1B,CAAC;YACD,WAAW,GAAG,EAAE,CAAC;YACjB,SAAS;QACX,CAAC;QACD,oDAAoD;QACpD,IAAI,IAAI,IAAI,IAAI,EAAE,WAAW,EAAE,KAAK,IAAI,IAAI,IAAI,KAAK,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;YACxE,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YACxB,WAAW,GAAG,IAAI,CAAC;YACnB,sCAAsC;QACxC,CAAC;aAAM,IACL,IAAI,EAAE,WAAW,EAAE,KAAK,IAAI;YAC5B,IAAI,KAAK,IAAI,CAAC,WAAW,EAAE;YAC3B,WAAW,CAAC,MAAM,GAAG,CAAC,EACtB,CAAC;YACD,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;YACrC,WAAW,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;QAC7C,CAAC;aAAM,CAAC;YACN,WAAW,IAAI,IAAI,CAAC;QACtB,CAAC;QACD,IAAI,GAAG,IAAI,CAAC;IACd,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACxB,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;AACvC,CAAC;AAED,SAAgB,SAAS,CAAC,MAA0B,EAAE,GAAW;IAC/D,OAAO,MAAM;QACX,CAAC,CAAC,GAAG,MAAM,IAAI,gCAAgC,CAAC,GAAG,CAAC,EAAE;QACtD,CAAC,CAAC,gCAAgC,CAAC,GAAG,CAAC,CAAC;AAC5C,CAAC"}