@cli-forge/parser 0.7.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 -117
  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 +331 -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,331 @@
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
+ * @hidden docs for {@link chain} are found on the main signature.
22
+ */
23
+ export declare function chain<T0, R>(initial: T0, fn0: UnaryFunction<T0, R>): R;
24
+ /**
25
+ * Applies a series of functions to an initial value, passing the result of each function to the next.
26
+ *
27
+ * Used to convert code that looks like:
28
+ * ```typescript
29
+ * const a = addB(addC({ a: 'a' }));
30
+ * ```
31
+ * to:
32
+ * ```typescript
33
+ * const a = chain({ a: 'a' }, addB, addC);
34
+ * ```
35
+ *
36
+ * See [composable-options](/examples/composable-options) for an example of how this can be used.
37
+ *
38
+ * @param initial Initial value to pass through the chain
39
+ * @param fns Functions to apply to the initial value, and each subsequent value
40
+ * @returns Updated value after all functions have been applied
41
+ * @hidden docs for {@link chain} are found on the main signature.
42
+ */
43
+ export declare function chain<T0, T1, R>(initial: T0, fn0: UnaryFunction<T0, T1>, fn1: UnaryFunction<T1, R>): R;
44
+ /**
45
+ * Applies a series of functions to an initial value, passing the result of each function to the next.
46
+ *
47
+ * Used to convert code that looks like:
48
+ * ```typescript
49
+ * const a = addB(addC({ a: 'a' }));
50
+ * ```
51
+ * to:
52
+ * ```typescript
53
+ * const a = chain({ a: 'a' }, addB, addC);
54
+ * ```
55
+ *
56
+ * See [composable-options](/examples/composable-options) for an example of how this can be used.
57
+ *
58
+ * @param initial Initial value to pass through the chain
59
+ * @param fns Functions to apply to the initial value, and each subsequent value
60
+ * @returns Updated value after all functions have been applied
61
+ * @hidden docs for {@link chain} are found on the main signature.
62
+ */
63
+ export declare function chain<T0, T1, T2, R>(initial: T0, fn0: UnaryFunction<T0, T1>, fn1: UnaryFunction<T1, T2>, fn2: UnaryFunction<T2, R>): R;
64
+ /**
65
+ * Applies a series of functions to an initial value, passing the result of each function to the next.
66
+ *
67
+ * Used to convert code that looks like:
68
+ * ```typescript
69
+ * const a = addB(addC({ a: 'a' }));
70
+ * ```
71
+ * to:
72
+ * ```typescript
73
+ * const a = chain({ a: 'a' }, addB, addC);
74
+ * ```
75
+ *
76
+ * See [composable-options](/examples/composable-options) for an example of how this can be used.
77
+ *
78
+ * @param initial Initial value to pass through the chain
79
+ * @param fns Functions to apply to the initial value, and each subsequent value
80
+ * @returns Updated value after all functions have been applied
81
+ * @hidden docs for {@link chain} are found on the main signature.
82
+ */
83
+ 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;
84
+ /**
85
+ * Applies a series of functions to an initial value, passing the result of each function to the next.
86
+ *
87
+ * Used to convert code that looks like:
88
+ * ```typescript
89
+ * const a = addB(addC({ a: 'a' }));
90
+ * ```
91
+ * to:
92
+ * ```typescript
93
+ * const a = chain({ a: 'a' }, addB, addC);
94
+ * ```
95
+ *
96
+ * See [composable-options](/examples/composable-options) for an example of how this can be used.
97
+ *
98
+ * @param initial Initial value to pass through the chain
99
+ * @param fns Functions to apply to the initial value, and each subsequent value
100
+ * @returns Updated value after all functions have been applied
101
+ * @hidden docs for {@link chain} are found on the main signature.
102
+ */
103
+ 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;
104
+ /**
105
+ * Applies a series of functions to an initial value, passing the result of each function to the next.
106
+ *
107
+ * Used to convert code that looks like:
108
+ * ```typescript
109
+ * const a = addB(addC({ a: 'a' }));
110
+ * ```
111
+ * to:
112
+ * ```typescript
113
+ * const a = chain({ a: 'a' }, addB, addC);
114
+ * ```
115
+ *
116
+ * See [composable-options](/examples/composable-options) for an example of how this can be used.
117
+ *
118
+ * @param initial Initial value to pass through the chain
119
+ * @param fns Functions to apply to the initial value, and each subsequent value
120
+ * @returns Updated value after all functions have been applied
121
+ * @hidden docs for {@link chain} are found on the main signature.
122
+ */
123
+ 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;
124
+ /**
125
+ * Applies a series of functions to an initial value, passing the result of each function to the next.
126
+ *
127
+ * Used to convert code that looks like:
128
+ * ```typescript
129
+ * const a = addB(addC({ a: 'a' }));
130
+ * ```
131
+ * to:
132
+ * ```typescript
133
+ * const a = chain({ a: 'a' }, addB, addC);
134
+ * ```
135
+ *
136
+ * See [composable-options](/examples/composable-options) for an example of how this can be used.
137
+ *
138
+ * @param initial Initial value to pass through the chain
139
+ * @param fns Functions to apply to the initial value, and each subsequent value
140
+ * @returns Updated value after all functions have been applied
141
+ * @hidden docs for {@link chain} are found on the main signature.
142
+ */
143
+ 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;
144
+ /**
145
+ * Applies a series of functions to an initial value, passing the result of each function to the next.
146
+ *
147
+ * Used to convert code that looks like:
148
+ * ```typescript
149
+ * const a = addB(addC({ a: 'a' }));
150
+ * ```
151
+ * to:
152
+ * ```typescript
153
+ * const a = chain({ a: 'a' }, addB, addC);
154
+ * ```
155
+ *
156
+ * See [composable-options](/examples/composable-options) for an example of how this can be used.
157
+ *
158
+ * @param initial Initial value to pass through the chain
159
+ * @param fns Functions to apply to the initial value, and each subsequent value
160
+ * @returns Updated value after all functions have been applied
161
+ * @hidden docs for {@link chain} are found on the main signature.
162
+ */
163
+ 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;
164
+ /**
165
+ * Applies a series of functions to an initial value, passing the result of each function to the next.
166
+ *
167
+ * Used to convert code that looks like:
168
+ * ```typescript
169
+ * const a = addB(addC({ a: 'a' }));
170
+ * ```
171
+ * to:
172
+ * ```typescript
173
+ * const a = chain({ a: 'a' }, addB, addC);
174
+ * ```
175
+ *
176
+ * See [composable-options](/examples/composable-options) for an example of how this can be used.
177
+ *
178
+ * @param initial Initial value to pass through the chain
179
+ * @param fns Functions to apply to the initial value, and each subsequent value
180
+ * @returns Updated value after all functions have been applied
181
+ * @hidden docs for {@link chain} are found on the main signature.
182
+ */
183
+ 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;
184
+ /**
185
+ * Applies a series of functions to an initial value, passing the result of each function to the next.
186
+ *
187
+ * Used to convert code that looks like:
188
+ * ```typescript
189
+ * const a = addB(addC({ a: 'a' }));
190
+ * ```
191
+ * to:
192
+ * ```typescript
193
+ * const a = chain({ a: 'a' }, addB, addC);
194
+ * ```
195
+ *
196
+ * See [composable-options](/examples/composable-options) for an example of how this can be used.
197
+ *
198
+ * @param initial Initial value to pass through the chain
199
+ * @param fns Functions to apply to the initial value, and each subsequent value
200
+ * @returns Updated value after all functions have been applied
201
+ * @hidden docs for {@link chain} are found on the main signature.
202
+ */
203
+ 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;
204
+ /**
205
+ * Applies a series of functions to an initial value, passing the result of each function to the next.
206
+ *
207
+ * Used to convert code that looks like:
208
+ * ```typescript
209
+ * const a = addB(addC({ a: 'a' }));
210
+ * ```
211
+ * to:
212
+ * ```typescript
213
+ * const a = chain({ a: 'a' }, addB, addC);
214
+ * ```
215
+ *
216
+ * See [composable-options](/examples/composable-options) for an example of how this can be used.
217
+ *
218
+ * @param initial Initial value to pass through the chain
219
+ * @param fns Functions to apply to the initial value, and each subsequent value
220
+ * @returns Updated value after all functions have been applied
221
+ * @hidden docs for {@link chain} are found on the main signature.
222
+ */
223
+ 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;
224
+ /**
225
+ * Applies a series of functions to an initial value, passing the result of each function to the next.
226
+ *
227
+ * Used to convert code that looks like:
228
+ * ```typescript
229
+ * const a = addB(addC({ a: 'a' }));
230
+ * ```
231
+ * to:
232
+ * ```typescript
233
+ * const a = chain({ a: 'a' }, addB, addC);
234
+ * ```
235
+ *
236
+ * See [composable-options](/examples/composable-options) for an example of how this can be used.
237
+ *
238
+ * @param initial Initial value to pass through the chain
239
+ * @param fns Functions to apply to the initial value, and each subsequent value
240
+ * @returns Updated value after all functions have been applied
241
+ * @hidden docs for {@link chain} are found on the main signature.
242
+ */
243
+ 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;
244
+ /**
245
+ * Applies a series of functions to an initial value, passing the result of each function to the next.
246
+ *
247
+ * Used to convert code that looks like:
248
+ * ```typescript
249
+ * const a = addB(addC({ a: 'a' }));
250
+ * ```
251
+ * to:
252
+ * ```typescript
253
+ * const a = chain({ a: 'a' }, addB, addC);
254
+ * ```
255
+ *
256
+ * See [composable-options](/examples/composable-options) for an example of how this can be used.
257
+ *
258
+ * @param initial Initial value to pass through the chain
259
+ * @param fns Functions to apply to the initial value, and each subsequent value
260
+ * @returns Updated value after all functions have been applied
261
+ * @hidden docs for {@link chain} are found on the main signature.
262
+ */
263
+ 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;
264
+ /**
265
+ * Applies a series of functions to an initial value, passing the result of each function to the next.
266
+ *
267
+ * Used to convert code that looks like:
268
+ * ```typescript
269
+ * const a = addB(addC({ a: 'a' }));
270
+ * ```
271
+ * to:
272
+ * ```typescript
273
+ * const a = chain({ a: 'a' }, addB, addC);
274
+ * ```
275
+ *
276
+ * See [composable-options](/examples/composable-options) for an example of how this can be used.
277
+ *
278
+ * @param initial Initial value to pass through the chain
279
+ * @param fns Functions to apply to the initial value, and each subsequent value
280
+ * @returns Updated value after all functions have been applied
281
+ * @hidden docs for {@link chain} are found on the main signature.
282
+ */
283
+ 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;
284
+ /**
285
+ * Applies a series of functions to an initial value, passing the result of each function to the next.
286
+ *
287
+ * Used to convert code that looks like:
288
+ * ```typescript
289
+ * const a = addB(addC({ a: 'a' }));
290
+ * ```
291
+ * to:
292
+ * ```typescript
293
+ * const a = chain({ a: 'a' }, addB, addC);
294
+ * ```
295
+ *
296
+ * See [composable-options](/examples/composable-options) for an example of how this can be used.
297
+ *
298
+ * @param initial Initial value to pass through the chain
299
+ * @param fns Functions to apply to the initial value, and each subsequent value
300
+ * @returns Updated value after all functions have been applied
301
+ * @hidden docs for {@link chain} are found on the main signature.
302
+ */
303
+ 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;
304
+ /**
305
+ * Applies a series of functions to an initial value, passing the result of each function to the next.
306
+ *
307
+ * Used to convert code that looks like:
308
+ * ```typescript
309
+ * const a = addB(addC({ a: 'a' }));
310
+ * ```
311
+ * to:
312
+ * ```typescript
313
+ * const a = chain({ a: 'a' }, addB, addC);
314
+ * ```
315
+ *
316
+ * See [composable-options](/examples/composable-options) for an example of how this can be used.
317
+ *
318
+ * @param {T0} initial Initial value to pass through the chain
319
+ * @param fns Functions to apply to the initial value, and each subsequent value
320
+ * @returns {R} Updated value after all functions have been applied
321
+ */
322
+ 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;
323
+ /**
324
+ * A composition helper to be used with {@link chain}.
325
+ *
326
+ * @param name The name of the option to add
327
+ * @param config The configuration for the option
328
+ * @returns A unary function that adds an option to an {@link ArgvParser}.
329
+ */
330
+ 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>; }>;
331
+ 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;;AA4kB/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,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ACD,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,CA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