@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cli-forge/parser",
3
- "version": "0.6.0",
3
+ "version": "0.8.0",
4
4
  "dependencies": {
5
5
  "tslib": "^2.3.0"
6
6
  },
package/src/index.d.ts CHANGED
@@ -1,3 +1,6 @@
1
1
  export * from './lib/parser';
2
- export * from './lib/utils';
2
+ export * from './lib/utils/case-transformations';
3
3
  export * from './lib/helpers';
4
+ export * from './lib/option-types';
5
+ export * from './lib/utils/read-default-value';
6
+ export * from './lib/utils/chain';
package/src/index.js CHANGED
@@ -2,6 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./lib/parser"), exports);
5
- tslib_1.__exportStar(require("./lib/utils"), exports);
5
+ tslib_1.__exportStar(require("./lib/utils/case-transformations"), exports);
6
6
  tslib_1.__exportStar(require("./lib/helpers"), exports);
7
+ tslib_1.__exportStar(require("./lib/option-types"), exports);
8
+ tslib_1.__exportStar(require("./lib/utils/read-default-value"), exports);
9
+ tslib_1.__exportStar(require("./lib/utils/chain"), exports);
7
10
  //# sourceMappingURL=index.js.map
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/parser/src/index.ts"],"names":[],"mappings":";;;AAAA,uDAA6B;AAC7B,sDAA4B;AAC5B,wDAA8B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/parser/src/index.ts"],"names":[],"mappings":";;;AAAA,uDAA6B;AAC7B,2EAAiD;AACjD,wDAA8B;AAC9B,6DAAmC;AACnC,yEAA+C;AAC/C,4DAAkC"}
@@ -0,0 +1,16 @@
1
+ import { CommonOptionConfig } from './common';
2
+ /**
3
+ * Configuration for array options. Arrays are parsed from
4
+ * comma separated, space separated, or multiple values.
5
+ *
6
+ * e.g. `--foo a b c`, `--foo a,b,c`, or `--foo a --foo b --foo c`
7
+ */
8
+ export type ArrayOptionConfig<TCoerce = string | number, TChoices = TCoerce[]> = StringArrayOptionConfig<TCoerce, TChoices> | NumberArrayOptionConfig<TCoerce, TChoices>;
9
+ export type NumberArrayOptionConfig<TCoerce = number, TChoices = number[]> = {
10
+ type: 'array';
11
+ items: 'number';
12
+ } & CommonOptionConfig<number[], TCoerce, TChoices>;
13
+ export type StringArrayOptionConfig<TCoerce = string, TChoices = TCoerce[]> = {
14
+ type: 'array';
15
+ items: 'string';
16
+ } & CommonOptionConfig<string[], TCoerce, TChoices>;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=array.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array.js","sourceRoot":"","sources":["../../../../../../packages/parser/src/lib/option-types/array.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ import { CommonOptionConfig } from './common';
2
+ export type BooleanOptionConfig<TCoerce = boolean, TChoices = TCoerce[]> = {
3
+ type: 'boolean';
4
+ } & CommonOptionConfig<boolean, TCoerce, TChoices>;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=boolean.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"boolean.js","sourceRoot":"","sources":["../../../../../../packages/parser/src/lib/option-types/boolean.ts"],"names":[],"mappings":""}
@@ -0,0 +1,78 @@
1
+ export type PlainDefaultValue<T> = T;
2
+ export type DefaultValueWithDescription<T> = {
3
+ value: PlainDefaultValue<T>;
4
+ description: string;
5
+ };
6
+ export type DefaultValueWithFactory<T> = {
7
+ factory: () => PlainDefaultValue<T>;
8
+ description: string;
9
+ };
10
+ export type Default<T> = PlainDefaultValue<T> | DefaultValueWithDescription<T> | DefaultValueWithFactory<T>;
11
+ export type CommonOptionConfig<T, TCoerce = T, TChoices = T[]> = {
12
+ /**
13
+ * If set to true, the option will be treated as a positional argument.
14
+ */
15
+ positional?: boolean;
16
+ /**
17
+ * Provide an array of aliases for the option.
18
+ */
19
+ alias?: string[];
20
+ /**
21
+ * Provide an array of choices for the option. Values not in the array will throw an error.
22
+ */
23
+ choices?: TChoices | (() => TChoices);
24
+ /**
25
+ * Provide a default value for the option.
26
+ *
27
+ * If the default value is a tuple, the first value will be used as the default value, and the second value will be used as the description.
28
+ */
29
+ default?: Default<T>;
30
+ /**
31
+ * Provide a description for the option.
32
+ */
33
+ description?: string;
34
+ /**
35
+ * Provide a function to coerce the value of the option.
36
+ * @param value Value of the option
37
+ * @returns Coerced value of the option
38
+ */
39
+ coerce?: (value: T) => TCoerce;
40
+ /**
41
+ * Provide a function to validate the value of the option.
42
+ * @param value Coerced value of the option
43
+ * @returns If the value is valid, return true. If the value is invalid, return false or a string with an error message.
44
+ */
45
+ validate?: (value: TCoerce) => boolean | string;
46
+ /**
47
+ * If true, the option is required.
48
+ */
49
+ required?: boolean;
50
+ /**
51
+ * If set, the option will be populated from the environment variable `${env}_${optionName}`.
52
+ * If set to true, the environment variable will be `${optionName}`.
53
+ * If explicitly set to false, environment variable population will be disabled for this option.
54
+ */
55
+ env?: string | boolean | {
56
+ /**
57
+ * What key should the value be read from in process.env
58
+ */
59
+ key: string;
60
+ /**
61
+ * If set to false, ignore prefix provided by .env() call.
62
+ */
63
+ prefix?: boolean;
64
+ };
65
+ /**
66
+ * If set, the option will be marked as deprecated, with the provided message. This will not effect runtime behavior,
67
+ * but will be displayed in help output and generated docs.
68
+ */
69
+ deprecated?: string;
70
+ /**
71
+ * If true, the option will not be displayed in help output or generated docs.
72
+ */
73
+ hidden?: boolean;
74
+ /**
75
+ * Can be set to group options in help output and generated docs.
76
+ */
77
+ group?: string;
78
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../../../../../packages/parser/src/lib/option-types/common.ts"],"names":[],"mappings":""}
@@ -0,0 +1,14 @@
1
+ import { OptionConfig } from './option-config';
2
+ export * from './option-config-to-type';
3
+ export * from './common';
4
+ export * from './array';
5
+ export * from './boolean';
6
+ export * from './number';
7
+ export * from './object';
8
+ export * from './string';
9
+ export { OptionConfig };
10
+ export type Internal<T extends OptionConfig> = T & InternalOptionConfig;
11
+ export type InternalOptionConfig = OptionConfig & {
12
+ key: string;
13
+ position?: number;
14
+ };
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./option-config-to-type"), exports);
5
+ tslib_1.__exportStar(require("./common"), exports);
6
+ tslib_1.__exportStar(require("./array"), exports);
7
+ tslib_1.__exportStar(require("./boolean"), exports);
8
+ tslib_1.__exportStar(require("./number"), exports);
9
+ tslib_1.__exportStar(require("./object"), exports);
10
+ tslib_1.__exportStar(require("./string"), exports);
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/parser/src/lib/option-types/index.ts"],"names":[],"mappings":";;;AAEA,kEAAwC;AACxC,mDAAyB;AACzB,kDAAwB;AACxB,oDAA0B;AAC1B,mDAAyB;AACzB,mDAAyB;AACzB,mDAAyB"}
@@ -0,0 +1,4 @@
1
+ import { CommonOptionConfig } from './common';
2
+ export type NumberOptionConfig<TCoerce = number, TChoices = TCoerce[]> = {
3
+ type: 'number';
4
+ } & CommonOptionConfig<number, TCoerce, TChoices>;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=number.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"number.js","sourceRoot":"","sources":["../../../../../../packages/parser/src/lib/option-types/number.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ import { CommonOptionConfig } from './common';
2
+ import { OptionConfig } from './option-config';
3
+ export interface ObjectOptionConfig<TCoerce = Record<string, string>, TProperties extends {
4
+ [key: string]: Readonly<OptionConfig>;
5
+ } = Record<string, any>> extends Omit<CommonOptionConfig<Record<string, string>, TCoerce>, 'choices'> {
6
+ type: 'object';
7
+ /** */
8
+ properties: TProperties;
9
+ additionalProperties?: false | 'string' | 'number' | 'boolean';
10
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=object.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object.js","sourceRoot":"","sources":["../../../../../../packages/parser/src/lib/option-types/object.ts"],"names":[],"mappings":""}
@@ -0,0 +1,20 @@
1
+ import { OptionConfig } from './option-config';
2
+ import { ArrayOptionConfig } from './array';
3
+ import { ObjectOptionConfig } from './object';
4
+ /**
5
+ * Converts an OptionConfig to the TypeScript type for the parsed value.
6
+ */
7
+ export type OptionConfigToType<TOptionConfig extends OptionConfig> = InferTChoice<TOptionConfig> extends [never] ? TOptionConfig['coerce'] extends (s: any) => any ? ReturnType<TOptionConfig['coerce']> : {
8
+ string: string;
9
+ number: number;
10
+ boolean: boolean;
11
+ array: ArrayItems<TOptionConfig>[];
12
+ object: TOptionConfig extends ObjectOptionConfig ? ResolveTProperties<TOptionConfig['properties']> & AdditionalProperties<TOptionConfig> : never;
13
+ }[TOptionConfig['type']] : InferTChoice<TOptionConfig>;
14
+ type ArrayItems<TOptionConfig extends OptionConfig> = TOptionConfig extends ArrayOptionConfig<string | number> ? TOptionConfig['items'] extends 'string' ? string : number : never;
15
+ type AdditionalProperties<TOptionConfig extends ObjectOptionConfig> = TOptionConfig['additionalProperties'] extends 'string' ? Record<string, string> : TOptionConfig['additionalProperties'] extends 'number' ? Record<string, number> : TOptionConfig['additionalProperties'] extends 'boolean' ? Record<string, boolean> : Record<string, never>;
16
+ type ResolveTProperties<TProperties extends Record<string, OptionConfig>> = {
17
+ [key in keyof TProperties]: OptionConfigToType<TProperties[key]>;
18
+ };
19
+ type InferTChoice<TOptionConfig> = 'choices' extends keyof TOptionConfig ? TOptionConfig['choices'] extends Array<infer TChoice> ? TChoice : TOptionConfig['choices'] extends () => Array<infer TChoice> ? TChoice : never : never;
20
+ export {};
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=option-config-to-type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"option-config-to-type.js","sourceRoot":"","sources":["../../../../../../packages/parser/src/lib/option-types/option-config-to-type.ts"],"names":[],"mappings":""}
@@ -0,0 +1,15 @@
1
+ import { ArrayOptionConfig } from './array';
2
+ import { BooleanOptionConfig } from './boolean';
3
+ import { NumberOptionConfig } from './number';
4
+ import { ObjectOptionConfig } from './object';
5
+ import { StringOptionConfig } from './string';
6
+ /**
7
+ * Configures an option for the parser. See subtypes for more information.
8
+ * - {@link StringOptionConfig}
9
+ * - {@link NumberOptionConfig}
10
+ * - {@link ArrayOptionConfig}
11
+ * - {@link BooleanOptionConfig}
12
+ *
13
+ * @typeParam TCoerce The return type of the `coerce` function if provided.
14
+ */
15
+ export type OptionConfig<TCoerce = any, TChoices = any[], TObjectProps extends Record<string, OptionConfig> = Record<string, any>> = StringOptionConfig<TCoerce, TChoices> | NumberOptionConfig<TCoerce, TChoices> | ArrayOptionConfig<TCoerce, TChoices> | BooleanOptionConfig<TCoerce, TChoices> | ObjectOptionConfig<TCoerce, TObjectProps>;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=option-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"option-config.js","sourceRoot":"","sources":["../../../../../../packages/parser/src/lib/option-types/option-config.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ import { CommonOptionConfig } from './common';
2
+ export type StringOptionConfig<TCoerce = string, TChoices = TCoerce[]> = {
3
+ type: 'string';
4
+ } & CommonOptionConfig<string, TCoerce, TChoices>;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=string.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string.js","sourceRoot":"","sources":["../../../../../../packages/parser/src/lib/option-types/string.ts"],"names":[],"mappings":""}
@@ -1,100 +1,6 @@
1
- type Flatten<T> = T extends Array<infer U> ? U : T;
2
- export type CommonOptionConfig<T, TCoerce = T> = {
3
- /**
4
- * If set to true, the option will be treated as a positional argument.
5
- */
6
- positional?: boolean;
7
- /**
8
- * Provide an array of aliases for the option.
9
- */
10
- alias?: string[];
11
- /**
12
- * Provide an array of choices for the option. Values not in the array will throw an error.
13
- */
14
- choices?: Flatten<T>[] | (() => Flatten<T>[]);
15
- /**
16
- * Provide a default value for the option.
17
- */
18
- default?: T;
19
- /**
20
- * Provide a description for the option.
21
- */
22
- description?: string;
23
- /**
24
- * Provide a function to coerce the value of the option.
25
- * @param value Value of the option
26
- * @returns Coerced value of the option
27
- */
28
- coerce?: (value: T) => TCoerce;
29
- /**
30
- * Provide a function to validate the value of the option.
31
- * @param value Coerced value of the option
32
- * @returns If the value is valid, return true. If the value is invalid, return false or a string with an error message.
33
- */
34
- validate?: (value: TCoerce) => boolean | string;
35
- /**
36
- * If true, the option is required.
37
- */
38
- required?: boolean;
39
- /**
40
- * If set, the option will be populated from the environment variable `${env}_${optionName}`.
41
- * If set to true, the environment variable will be `${optionName}`.
42
- * If explicitly set to false, environment variable population will be disabled for this option.
43
- */
44
- env?: string | boolean | {
45
- /**
46
- * What key should the value be read from in process.env
47
- */
48
- key: string;
49
- /**
50
- * If set to false, ignore prefix provided by .env() call.
51
- */
52
- prefix?: boolean;
53
- };
54
- /**
55
- * If set, the option will be marked as deprecated, with the provided message. This will not effect runtime behavior,
56
- * but will be displayed in help output and generated docs.
57
- */
58
- deprecated?: string;
59
- };
60
- export type StringOptionConfig<TCoerce = string> = {
61
- type: 'string';
62
- } & CommonOptionConfig<string, TCoerce>;
63
- export type NumberOptionConfig<TCoerce = number> = {
64
- type: 'number';
65
- } & CommonOptionConfig<number, TCoerce>;
66
- export type BooleanOptionConfig<TCoerce = boolean> = {
67
- type: 'boolean';
68
- } & CommonOptionConfig<boolean, TCoerce>;
69
- export type StringArrayOptionConfig<TCoerce = string> = {
70
- type: 'array';
71
- items: 'string';
72
- } & CommonOptionConfig<string[], TCoerce>;
73
- export type NumberArrayOptionConfig<TCoerce = number> = {
74
- type: 'array';
75
- items: 'number';
76
- } & CommonOptionConfig<number[], TCoerce>;
77
- /**
78
- * Configuration for array options. Arrays are parsed from
79
- * comma separated, space separated, or multiple values.
80
- *
81
- * e.g. `--foo a b c`, `--foo a,b,c`, or `--foo a --foo b --foo c`
82
- */
83
- export type ArrayOptionConfig<TCoerce = string | number> = StringArrayOptionConfig<TCoerce> | NumberArrayOptionConfig<TCoerce>;
84
- /**
85
- * Configures an option for the parser. See subtypes for more information.
86
- * - {@link StringOptionConfig}
87
- * - {@link NumberOptionConfig}
88
- * - {@link ArrayOptionConfig}
89
- * - {@link BooleanOptionConfig}
90
- *
91
- * @typeParam TCoerce The return type of the `coerce` function if provided.
92
- */
93
- export type OptionConfig<TCoerce = any> = StringOptionConfig<TCoerce> | NumberOptionConfig<TCoerce> | ArrayOptionConfig<TCoerce> | BooleanOptionConfig<TCoerce>;
94
- type InternalOptionConfig = OptionConfig & {
95
- key: string;
96
- position?: number;
97
- };
1
+ import { OptionConfigToType } from './option-types/option-config-to-type';
2
+ import { InternalOptionConfig, OptionConfig } from './option-types';
3
+ import { Parser, ParserContext } from './parsers/typings';
98
4
  /**
99
5
  * Base type for parsed arguments.
100
6
  */
@@ -188,19 +94,16 @@ export declare class ArgvParser<TArgs extends ParsedArgs = {
188
94
  * @param config The configuration for the option. See {@link OptionConfig}
189
95
  * @returns Updated parser instance with the new option registered.
190
96
  */
191
- option<TOption extends string, TOptionConfig extends OptionConfig>(name: TOption, config: TOptionConfig): ArgvParser<TArgs & { [key in TOption]: TOptionConfig["coerce"] extends (s: any) => any ? ReturnType<TOptionConfig["coerce"]> : {
192
- string: string;
193
- number: number;
194
- boolean: boolean;
195
- array: (TOptionConfig extends ArrayOptionConfig ? TOptionConfig["items"] extends "string" ? string : number : never)[];
196
- }[TOptionConfig["type"]]; }>;
97
+ option<TOption extends string, const TOptionConfig extends OptionConfig<any>>(name: TOption, config: TOptionConfig): ArgvParser<TArgs & { [key in TOption]: OptionConfigToType<TOptionConfig>; }>;
197
98
  /**
198
99
  * Registers a new positional argument with the parser.
199
100
  * @param name The name of the positional argument
200
101
  * @param config The configuration for the positional argument. See {@link OptionConfig}
201
102
  * @returns Updated parser instance with the new positional argument registered.
202
103
  */
203
- positional<TOption extends string>(name: TOption, config: OptionConfig): ArgvParser<TArgs & { [key in TOption]: string | number | boolean | (string | number)[]; }>;
104
+ positional<TOption extends string, const TOptionConfig extends OptionConfig<any>>(name: TOption, config: TOptionConfig): ArgvParser<TArgs & { [key in TOption]: OptionConfigToType<TOptionConfig & {
105
+ readonly positional: true;
106
+ }>; }>;
204
107
  /**
205
108
  * Enables environment variable population for options.
206
109
  * @param envPrefix Prefix for environment variables. The full environment variable name will be `${envPrefix}_${optionName}`.
@@ -244,12 +147,8 @@ export declare class ArgvParser<TArgs extends ParsedArgs = {
244
147
  export declare function parser(opts?: ParserOptions): ArgvParser<{
245
148
  unmatched: string[];
246
149
  }>;
247
- export declare class NoValueError extends Error {
248
- constructor();
249
- }
250
- type Parser<TConfig extends OptionConfig, T = any> = (config: TConfig, tokens: string[], current?: T) => T;
150
+ export declare function tryParseValue(parser: Parser<InternalOptionConfig>, input: ParserContext<InternalOptionConfig>): any;
251
151
  export declare class ValidationFailedError<T> extends AggregateError {
252
152
  partialArgV: Partial<T>;
253
153
  constructor(errors: Error[], message: string, partialArgV: Partial<T>);
254
154
  }
255
- export {};