massarg 1.0.7-pre.1 → 2.0.0-pre.2

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.
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,gDAAyB;AACzB,uDAAgC;AAChC,+DAAwC;AACxC,8CAAuB;AAEvB,iCAA4E;AAC5E,mCAAwC;AACxC,2CAAiG;AAEjG;IAiCE;QA/BQ,aAAQ,GAA8B,EAAE,CAAA;QACxC,cAAS,GAA0B,EAAE,CAAA;QAErC,cAAS,GAAiB,EAAE,CAAA;QAC5B,gBAAW,GAAG,CAAC,CAAA;QACvB;;gDAEwC;QACjC,SAAI,GAA0B,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,EAAc,EAA2B,CAAA;QAE7F,UAAK,GAAsB;YACjC,OAAO,EAAE,SAAgB;YACzB,YAAY,EAAE,KAAK;YACnB,eAAe,EAAE,QAAQ;YACzB,WAAW,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC;YAC9B,cAAc,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC;YAC/B,UAAU,EAAE,OAAO;YACnB,UAAU,EAAE,EAAE;YACd,MAAM,EAAE,EAAE;YACV,MAAM,EAAE,EAAE;YACV,oBAAoB,EAAE,KAAK;YAC3B,mBAAmB,EAAE,GAAG;YACxB,gBAAgB,EAAE,IAAI;YACtB,YAAY,EAAE,qBAAqB;YACnC,SAAS,EAAE,IAAI;YACf,eAAe,EAAE,IAAI;YACrB,kBAAkB,EAAE,GAAG;YACvB,mBAAmB,EAAE,GAAG;SACzB,CAAA;QACO,qBAAgB,GAAoD,EAAE,CAAA;QAG5E,IAAI,CAAC,MAAM,CAAC;YACV,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE,CAAC,GAAG,CAA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UAAc,KAAkC;;QAAE,cAAc;aAAd,UAAc,EAAd,qBAAc,EAAd,IAAc;YAAd,6BAAc;;QAC9D,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE;YACzB,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;SACtB;QACD,IAAI,MAAM,GAAW,SAAgB,CAAA;;YACrC,KAAgB,IAAA,KAAA,SAAA,IAAA,eAAO,EAAC,KAAK,CAAC,CAAA,gBAAA,4BAAE;gBAA3B,IAAM,CAAC,WAAA;gBACV,MAAM,GAAI,eAAK,CAAC,CAAuB,CAAC,OAA9B,eAAK,2BAAkD,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,UAAC,CAAA;aAC7F;;;;;;;;;QACD,OAAO,eAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;IAC5B,CAAC;IAEO,4BAAU,GAAlB;QAAmB,gBAAgB;aAAhB,UAAgB,EAAhB,qBAAgB,EAAhB,IAAgB;YAAhB,2BAAgB;;QACjC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE;YACzB,OAAO,CAAC,CAAA;SACT;QACD,OAAO,kBAAU,wCAAI,MAAM,WAAC;IAC9B,CAAC;IACH,cAAC;AAAD,CAAC,AAxiBD,IAwiBC;AAxiBY,0BAAO;AA0iBpB,SAAgB,OAAO;IACrB,OAAO,IAAI,OAAO,EAAK,CAAA;AACzB,CAAC;AAFD,0BAEC;AAED,kBAAe,OAAO,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAAyB"}
package/massarg.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import { ArgsObject, CommandConfig, MassargCommand } from './command';
2
+ type MinimalCommandConfig<Args extends ArgsObject> = Omit<CommandConfig<Args>, 'aliases' | 'run'> & Partial<Pick<CommandConfig<Args>, 'aliases' | 'run'>>;
3
+ export declare class Massarg<Args extends ArgsObject = ArgsObject> extends MassargCommand<Args> {
4
+ constructor(options: MinimalCommandConfig<Args>);
5
+ }
6
+ export declare function massarg<Args extends ArgsObject = ArgsObject>(options: MinimalCommandConfig<Args>): MassargCommand<Args>;
7
+ export {};
8
+ //# sourceMappingURL=massarg.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"massarg.d.ts","sourceRoot":"","sources":["../src/massarg.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAErE,KAAK,oBAAoB,CAAC,IAAI,SAAS,UAAU,IAAI,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,SAAS,GAAG,KAAK,CAAC,GAC/F,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,SAAS,GAAG,KAAK,CAAC,CAAC,CAAA;AAEvD,qBAAa,OAAO,CAAC,IAAI,SAAS,UAAU,GAAG,UAAU,CAAE,SAAQ,cAAc,CAAC,IAAI,CAAC;gBACzE,OAAO,EAAE,oBAAoB,CAAC,IAAI,CAAC;CAWhD;AAED,wBAAgB,OAAO,CAAC,IAAI,SAAS,UAAU,GAAG,UAAU,EAC1D,OAAO,EAAE,oBAAoB,CAAC,IAAI,CAAC,GAClC,cAAc,CAAC,IAAI,CAAC,CAEtB"}
package/massarg.js ADDED
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.massarg = exports.Massarg = void 0;
4
+ const command_1 = require("./command");
5
+ class Massarg extends command_1.MassargCommand {
6
+ constructor(options) {
7
+ // TODO consider re-using name and description for general help, and pass them to super
8
+ super({
9
+ aliases: [],
10
+ run: () => {
11
+ console.log(this.helpString());
12
+ // throw new Error("No main command provided")
13
+ },
14
+ ...options,
15
+ });
16
+ }
17
+ }
18
+ exports.Massarg = Massarg;
19
+ function massarg(options) {
20
+ return new Massarg(options);
21
+ }
22
+ exports.massarg = massarg;
23
+ //# sourceMappingURL=massarg.js.map
package/massarg.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"massarg.js","sourceRoot":"","sources":["../src/massarg.ts"],"names":[],"mappings":";;;AAAA,uCAAqE;AAKrE,MAAa,OAA8C,SAAQ,wBAAoB;IACrF,YAAY,OAAmC;QAC7C,uFAAuF;QACvF,KAAK,CAAC;YACJ,OAAO,EAAE,EAAE;YACX,GAAG,EAAE,GAAG,EAAE;gBACR,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAA;gBAC9B,8CAA8C;YAChD,CAAC;YACD,GAAG,OAAO;SACX,CAAC,CAAA;IACJ,CAAC;CACF;AAZD,0BAYC;AAED,SAAgB,OAAO,CACrB,OAAmC;IAEnC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,CAAA;AAC7B,CAAC;AAJD,0BAIC"}
package/option.d.ts ADDED
@@ -0,0 +1,244 @@
1
+ import { z } from 'zod';
2
+ import { ArgsObject } from './command';
3
+ export declare const OptionConfig: <OptionType, Args extends object = object>(type: z.ZodType<OptionType, z.ZodTypeDef, OptionType>) => z.ZodObject<{
4
+ /** Name of the option */
5
+ name: z.ZodString;
6
+ /** Description of the option, displayed in the help output */
7
+ description: z.ZodString;
8
+ /** Default value of the option */
9
+ defaultValue: z.ZodOptional<z.ZodAny>;
10
+ /** Aliases for the option, which can be used with the shorthand option notation. */
11
+ aliases: z.ZodArray<z.ZodString, "many">;
12
+ /**
13
+ * Parse the value of the option. You can return any type here, or throw an error if the value
14
+ * is invalid.
15
+ */
16
+ parse: z.ZodOptional<z.ZodType<Parser<Args, OptionType>, z.ZodTypeDef, Parser<Args, OptionType>>>;
17
+ /**
18
+ * Whether the option is an array.
19
+ *
20
+ * Array options can be specified multiple times, and the values will be collected into an array.
21
+ *
22
+ * Normally, specifying an option multiple times will override the previous value.
23
+ */
24
+ array: z.ZodOptional<z.ZodBoolean>;
25
+ /** Whether the option is required. If it is required, parsing will throw an error if it's not
26
+ * present.
27
+ */
28
+ required: z.ZodOptional<z.ZodBoolean>;
29
+ /** Whether the option is the default option. The default option is the option that is used if
30
+ * no other option is specified, e.g. a value is passed in without an option name.
31
+ *
32
+ * Note that if commands match the same argument first, they will be used instead of the default
33
+ * option.
34
+ */
35
+ isDefault: z.ZodOptional<z.ZodBoolean>;
36
+ /** Whether the option is hidden. Hidden options are not displayed in the help output. */
37
+ hidden: z.ZodOptional<z.ZodBoolean>;
38
+ /** Specify a custom name for the output, which will be used when parsing the args. */
39
+ outputName: z.ZodOptional<z.ZodString>;
40
+ }, "strip", z.ZodTypeAny, {
41
+ description: string;
42
+ name: string;
43
+ aliases: string[];
44
+ defaultValue?: any;
45
+ parse?: Parser<Args, OptionType> | undefined;
46
+ array?: boolean | undefined;
47
+ required?: boolean | undefined;
48
+ isDefault?: boolean | undefined;
49
+ hidden?: boolean | undefined;
50
+ outputName?: string | undefined;
51
+ }, {
52
+ description: string;
53
+ name: string;
54
+ aliases: string[];
55
+ defaultValue?: any;
56
+ parse?: Parser<Args, OptionType> | undefined;
57
+ array?: boolean | undefined;
58
+ required?: boolean | undefined;
59
+ isDefault?: boolean | undefined;
60
+ hidden?: boolean | undefined;
61
+ outputName?: string | undefined;
62
+ }>;
63
+ export type OptionConfig<T = unknown, Args extends ArgsObject = ArgsObject> = z.infer<ReturnType<typeof OptionConfig<T, Args>>>;
64
+ export type Parser<Args extends ArgsObject = ArgsObject, OptionType extends any = any> = (x: string, y: Args) => OptionType;
65
+ export declare const TypedOptionConfig: <OptionType, Args extends object = object>(type: z.ZodType<OptionType, z.ZodTypeDef, OptionType>) => z.ZodObject<{
66
+ array: z.ZodOptional<z.ZodBoolean>;
67
+ description: z.ZodString;
68
+ name: z.ZodString;
69
+ defaultValue: z.ZodOptional<z.ZodAny>;
70
+ aliases: z.ZodArray<z.ZodString, "many">;
71
+ required: z.ZodOptional<z.ZodBoolean>;
72
+ isDefault: z.ZodOptional<z.ZodBoolean>;
73
+ hidden: z.ZodOptional<z.ZodBoolean>;
74
+ outputName: z.ZodOptional<z.ZodString>;
75
+ parse: z.ZodOptional<z.ZodType<Parser<Args, OptionType>, z.ZodTypeDef, Parser<Args, OptionType>>>;
76
+ type: z.ZodOptional<z.ZodEnum<["number"]>>;
77
+ }, "strip", z.ZodTypeAny, {
78
+ description: string;
79
+ name: string;
80
+ aliases: string[];
81
+ array?: boolean | undefined;
82
+ defaultValue?: any;
83
+ required?: boolean | undefined;
84
+ isDefault?: boolean | undefined;
85
+ hidden?: boolean | undefined;
86
+ outputName?: string | undefined;
87
+ parse?: Parser<Args, OptionType> | undefined;
88
+ type?: "number" | undefined;
89
+ }, {
90
+ description: string;
91
+ name: string;
92
+ aliases: string[];
93
+ array?: boolean | undefined;
94
+ defaultValue?: any;
95
+ required?: boolean | undefined;
96
+ isDefault?: boolean | undefined;
97
+ hidden?: boolean | undefined;
98
+ outputName?: string | undefined;
99
+ parse?: Parser<Args, OptionType> | undefined;
100
+ type?: "number" | undefined;
101
+ }>;
102
+ export type TypedOptionConfig<T, A extends ArgsObject = ArgsObject> = z.infer<ReturnType<typeof TypedOptionConfig<T, A>>>;
103
+ /**
104
+ * @see OptionConfig
105
+ * @see ArrayOptionConfig
106
+ */
107
+ export declare const ArrayOptionConfig: <T, A extends object = object>(type: z.ZodType<T, z.ZodTypeDef, T>) => z.ZodObject<{
108
+ type: z.ZodOptional<z.ZodEnum<["number"]>>;
109
+ array: z.ZodOptional<z.ZodBoolean>;
110
+ description: z.ZodString;
111
+ name: z.ZodString;
112
+ aliases: z.ZodArray<z.ZodString, "many">;
113
+ required: z.ZodOptional<z.ZodBoolean>;
114
+ isDefault: z.ZodOptional<z.ZodBoolean>;
115
+ hidden: z.ZodOptional<z.ZodBoolean>;
116
+ outputName: z.ZodOptional<z.ZodString>;
117
+ parse: z.ZodOptional<z.ZodType<Parser<A, T[]>, z.ZodTypeDef, Parser<A, T[]>>>;
118
+ defaultValue: z.ZodOptional<z.ZodArray<z.ZodType<T, z.ZodTypeDef, T>, "many">>;
119
+ }, "strip", z.ZodTypeAny, {
120
+ description: string;
121
+ name: string;
122
+ aliases: string[];
123
+ type?: "number" | undefined;
124
+ array?: boolean | undefined;
125
+ required?: boolean | undefined;
126
+ isDefault?: boolean | undefined;
127
+ hidden?: boolean | undefined;
128
+ outputName?: string | undefined;
129
+ parse?: Parser<A, T[]> | undefined;
130
+ defaultValue?: T[] | undefined;
131
+ }, {
132
+ description: string;
133
+ name: string;
134
+ aliases: string[];
135
+ type?: "number" | undefined;
136
+ array?: boolean | undefined;
137
+ required?: boolean | undefined;
138
+ isDefault?: boolean | undefined;
139
+ hidden?: boolean | undefined;
140
+ outputName?: string | undefined;
141
+ parse?: Parser<A, T[]> | undefined;
142
+ defaultValue?: T[] | undefined;
143
+ }>;
144
+ /**
145
+ * An option that can be passed to a command.
146
+ *
147
+ * This type represents an array option, which can be specified multiple times.
148
+ */
149
+ export type ArrayOptionConfig<T = unknown> = z.infer<ReturnType<typeof ArrayOptionConfig<z.ZodType<T>>>>;
150
+ /** @internal */
151
+ export type ArgvValue<T> = {
152
+ argv: string[];
153
+ value: T;
154
+ key: string;
155
+ };
156
+ /**
157
+ * An option that can be passed to a command.
158
+ *
159
+ * Options can be specified in two ways:
160
+ *
161
+ * - Using the long form, e.g. `--option value`
162
+ * - Using the short form, e.g. `-o value`
163
+ *
164
+ * They can also have a parse function, which will be used to parse the value passed in from the
165
+ * original argument (string).
166
+ *
167
+ * @example
168
+ * ```ts
169
+ * massarg(options).option({
170
+ * name: 'option',
171
+ * description: 'An option',
172
+ * defaultValue: 'default',
173
+ * aliases: ['o'],
174
+ * parse: (value) => value.toUpperCase(),
175
+ * })
176
+ * ```
177
+ */
178
+ export declare class MassargOption<OptionType extends any = unknown, Args extends ArgsObject = ArgsObject> {
179
+ name: string;
180
+ description: string;
181
+ defaultValue?: OptionType;
182
+ aliases: string[];
183
+ parse: Parser<Args, OptionType>;
184
+ isArray: boolean;
185
+ isDefault: boolean;
186
+ outputName?: string;
187
+ constructor(options: OptionConfig<OptionType, Args>);
188
+ static fromTypedConfig<T = unknown, A extends ArgsObject = ArgsObject>(config: TypedOptionConfig<T, A>): MassargOption<T>;
189
+ getOutputName(): string;
190
+ _parseDetails(argv: string[], options: ArgsObject): ArgvValue<OptionType>;
191
+ helpString(): string;
192
+ _match(arg: string): boolean;
193
+ _isOption(arg: string): boolean;
194
+ static getName(arg: string): string;
195
+ }
196
+ /**
197
+ * An option that can be passed to a command.
198
+ *
199
+ * This type of option parses a number, and fails if it is not a valid number.
200
+ *
201
+ * @example
202
+ * ```ts
203
+ * massarg(options).option({
204
+ * name: 'number',
205
+ * description: 'A number',
206
+ * defaultValue: 0,
207
+ * aliases: ['n'],
208
+ * type: 'number',
209
+ * })
210
+ * ```
211
+ */
212
+ export declare class MassargNumber extends MassargOption<number> {
213
+ constructor(options: Omit<OptionConfig<number>, 'parse'>);
214
+ _parseDetails(argv: string[], options: ArgsObject): ArgvValue<number>;
215
+ }
216
+ /**
217
+ * An option that can be passed to a command.
218
+ *
219
+ * A flag is an option that is either present or not. It can be used to toggle
220
+ * a boolean value, or to indicate that a command should be run in a different
221
+ * mode.
222
+ *
223
+ * A flag can be negated by prefixing it with `no-`. For example, `--no-verbose`,
224
+ * or by prefixing the alias with `^` instead of `-`. This is configurable via the command's
225
+ * configuration.
226
+ *
227
+ * @example
228
+ * ```ts
229
+ * massarg.flag({
230
+ * name: 'verbose',
231
+ * aliases: ['v'],
232
+ * description: 'Enable verbose logging',
233
+ * defaultValue: false,
234
+ * })
235
+ * ```
236
+ */
237
+ export declare class MassargFlag extends MassargOption<boolean> {
238
+ constructor(options: Omit<OptionConfig<boolean>, 'parse'>);
239
+ _parseDetails(argv: string[]): ArgvValue<boolean>;
240
+ }
241
+ export declare class MassargHelpFlag extends MassargFlag {
242
+ constructor(config?: Partial<Omit<OptionConfig<boolean>, 'parse'>>);
243
+ }
244
+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C;AAED;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,aAAc,SAAQ,aAAa,CAAC,MAAM,CAAC;gBAC1C,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAOxD,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,UAAU,GAAG,SAAS,CAAC,MAAM,CAAC;CAwBtE;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,WAAY,SAAQ,aAAa,CAAC,OAAO,CAAC;gBACzC,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAOzD,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC,OAAO,CAAC;CA6BlD;AAED,qBAAa,eAAgB,SAAQ,WAAW;gBAClC,MAAM,GAAE,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAM;CAQvE"}
package/option.js ADDED
@@ -0,0 +1,308 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MassargHelpFlag = exports.MassargFlag = exports.MassargNumber = exports.MassargOption = exports.ArrayOptionConfig = exports.TypedOptionConfig = exports.OptionConfig = void 0;
4
+ const zod_1 = require("zod");
5
+ const error_1 = require("./error");
6
+ const utils_1 = require("./utils");
7
+ const OptionConfig = (type) => zod_1.z.object({
8
+ /** Name of the option */
9
+ name: zod_1.z.string(),
10
+ /** Description of the option, displayed in the help output */
11
+ description: zod_1.z.string(),
12
+ /** Default value of the option */
13
+ defaultValue: zod_1.z.any().optional(),
14
+ /** Aliases for the option, which can be used with the shorthand option notation. */
15
+ aliases: zod_1.z.string().array(),
16
+ /**
17
+ * Parse the value of the option. You can return any type here, or throw an error if the value
18
+ * is invalid.
19
+ */
20
+ parse: zod_1.z.function().args(zod_1.z.string(), zod_1.z.any()).returns(type).optional(),
21
+ /**
22
+ * Whether the option is an array.
23
+ *
24
+ * Array options can be specified multiple times, and the values will be collected into an array.
25
+ *
26
+ * Normally, specifying an option multiple times will override the previous value.
27
+ */
28
+ array: zod_1.z.boolean().optional(),
29
+ /** Whether the option is required. If it is required, parsing will throw an error if it's not
30
+ * present.
31
+ */
32
+ required: zod_1.z.boolean().optional(),
33
+ /** Whether the option is the default option. The default option is the option that is used if
34
+ * no other option is specified, e.g. a value is passed in without an option name.
35
+ *
36
+ * Note that if commands match the same argument first, they will be used instead of the default
37
+ * option.
38
+ */
39
+ isDefault: zod_1.z.boolean().optional(),
40
+ /** Whether the option is hidden. Hidden options are not displayed in the help output. */
41
+ hidden: zod_1.z.boolean().optional(),
42
+ /** Specify a custom name for the output, which will be used when parsing the args. */
43
+ outputName: zod_1.z.string().optional(),
44
+ });
45
+ exports.OptionConfig = OptionConfig;
46
+ const TypedOptionConfig = (type) => (0, exports.OptionConfig)(type).merge(zod_1.z.object({
47
+ type: zod_1.z.enum(['number']).optional(),
48
+ }));
49
+ exports.TypedOptionConfig = TypedOptionConfig;
50
+ /**
51
+ * @see OptionConfig
52
+ * @see ArrayOptionConfig
53
+ */
54
+ const ArrayOptionConfig = (type) => (0, exports.TypedOptionConfig)(zod_1.z.array(type)).merge(
55
+ // OptionConfig(z.array(type)).merge(
56
+ zod_1.z.object({
57
+ defaultValue: zod_1.z.array(type).optional(),
58
+ }));
59
+ exports.ArrayOptionConfig = ArrayOptionConfig;
60
+ // TODO turn to options
61
+ const OPT_FULL_PREFIX = '--';
62
+ const OPT_SHORT_PREFIX = '-';
63
+ const NEGATE_FULL_PREFIX = 'no-';
64
+ const NEGATE_SHORT_PREFIX = '^';
65
+ /**
66
+ * An option that can be passed to a command.
67
+ *
68
+ * Options can be specified in two ways:
69
+ *
70
+ * - Using the long form, e.g. `--option value`
71
+ * - Using the short form, e.g. `-o value`
72
+ *
73
+ * They can also have a parse function, which will be used to parse the value passed in from the
74
+ * original argument (string).
75
+ *
76
+ * @example
77
+ * ```ts
78
+ * massarg(options).option({
79
+ * name: 'option',
80
+ * description: 'An option',
81
+ * defaultValue: 'default',
82
+ * aliases: ['o'],
83
+ * parse: (value) => value.toUpperCase(),
84
+ * })
85
+ * ```
86
+ */
87
+ class MassargOption {
88
+ constructor(options) {
89
+ (0, exports.OptionConfig)(zod_1.z.any()).parse(options);
90
+ this.name = options.name;
91
+ this.description = options.description;
92
+ this.defaultValue = options.defaultValue;
93
+ this.aliases = options.aliases;
94
+ this.parse = options.parse ?? ((x) => x);
95
+ this.isArray = options.array ?? false;
96
+ this.isDefault = options.isDefault ?? false;
97
+ this.outputName = options.outputName;
98
+ }
99
+ static fromTypedConfig(config) {
100
+ switch (config.type) {
101
+ case 'number':
102
+ return new MassargNumber(config);
103
+ }
104
+ return new MassargOption(config);
105
+ }
106
+ getOutputName() {
107
+ return this.outputName || (0, utils_1.toCamelCase)(this.name);
108
+ }
109
+ _parseDetails(argv, options) {
110
+ // TODO: support --option=value
111
+ let input = '';
112
+ try {
113
+ if (!this._match(argv[0])) {
114
+ throw new error_1.ParseError({
115
+ path: [this.name],
116
+ code: 'invalid_option',
117
+ message: `Expected option ${this.name}`,
118
+ received: JSON.stringify(argv[0]),
119
+ });
120
+ }
121
+ argv.shift();
122
+ input = argv.shift();
123
+ const value = this.parse(input, options);
124
+ return { key: this.getOutputName(), value, argv };
125
+ }
126
+ catch (e) {
127
+ if ((0, error_1.isZodError)(e)) {
128
+ throw new error_1.ParseError({
129
+ path: [this.name, ...e.issues[0].path.map((p) => p.toString())],
130
+ code: e.issues[0].code,
131
+ message: e.issues[0].message,
132
+ received: JSON.stringify(input),
133
+ });
134
+ }
135
+ throw e;
136
+ }
137
+ }
138
+ helpString() {
139
+ const aliases = this.aliases.length ? `|${this.aliases.join('|-')}` : '';
140
+ return `--${this.name}${aliases} ${this.description}`;
141
+ }
142
+ _match(arg) {
143
+ if (!arg)
144
+ return false;
145
+ // full prefix
146
+ if (arg.startsWith(OPT_FULL_PREFIX)) {
147
+ // negate full prefix
148
+ if (arg.startsWith(`--${NEGATE_FULL_PREFIX}`)) {
149
+ return this.name === arg.slice(`--${NEGATE_FULL_PREFIX}`.length);
150
+ }
151
+ return this.name === arg.slice(OPT_FULL_PREFIX.length);
152
+ }
153
+ // short prefix
154
+ if (arg.startsWith(OPT_SHORT_PREFIX) || arg.startsWith(NEGATE_SHORT_PREFIX)) {
155
+ return this.aliases.includes(arg.slice(OPT_SHORT_PREFIX.length));
156
+ }
157
+ // negate short prefix
158
+ if (arg.startsWith(NEGATE_SHORT_PREFIX)) {
159
+ return this.aliases.includes(arg.slice(NEGATE_SHORT_PREFIX.length));
160
+ }
161
+ // no prefix
162
+ return false;
163
+ }
164
+ _isOption(arg) {
165
+ return (arg.startsWith(OPT_FULL_PREFIX) ||
166
+ arg.startsWith(OPT_SHORT_PREFIX) ||
167
+ arg.startsWith(NEGATE_SHORT_PREFIX));
168
+ }
169
+ static getName(arg) {
170
+ if (arg.startsWith(OPT_FULL_PREFIX)) {
171
+ // negate full prefix
172
+ if (arg.startsWith(`--${NEGATE_FULL_PREFIX}`)) {
173
+ return arg.slice(`--${NEGATE_FULL_PREFIX}`.length);
174
+ }
175
+ return arg.slice(OPT_FULL_PREFIX.length);
176
+ }
177
+ // short prefix
178
+ if (arg.startsWith(OPT_SHORT_PREFIX) || arg.startsWith(NEGATE_SHORT_PREFIX)) {
179
+ return arg.slice(OPT_SHORT_PREFIX.length);
180
+ }
181
+ // negate short prefix
182
+ if (arg.startsWith(NEGATE_SHORT_PREFIX)) {
183
+ return arg.slice(NEGATE_SHORT_PREFIX.length);
184
+ }
185
+ return '<blank>';
186
+ }
187
+ }
188
+ exports.MassargOption = MassargOption;
189
+ /**
190
+ * An option that can be passed to a command.
191
+ *
192
+ * This type of option parses a number, and fails if it is not a valid number.
193
+ *
194
+ * @example
195
+ * ```ts
196
+ * massarg(options).option({
197
+ * name: 'number',
198
+ * description: 'A number',
199
+ * defaultValue: 0,
200
+ * aliases: ['n'],
201
+ * type: 'number',
202
+ * })
203
+ * ```
204
+ */
205
+ class MassargNumber extends MassargOption {
206
+ constructor(options) {
207
+ super({
208
+ ...options,
209
+ parse: (value) => Number(value),
210
+ });
211
+ }
212
+ _parseDetails(argv, options) {
213
+ try {
214
+ const { argv: _argv, value } = super._parseDetails(argv, options);
215
+ if (isNaN(value)) {
216
+ throw new error_1.ParseError({
217
+ path: [this.name],
218
+ code: 'invalid_type',
219
+ message: 'Expected a number',
220
+ received: JSON.stringify(argv[0]),
221
+ });
222
+ }
223
+ return { key: this.name, value, argv: _argv };
224
+ }
225
+ catch (e) {
226
+ if ((0, error_1.isZodError)(e)) {
227
+ throw new error_1.ParseError({
228
+ path: [this.name, ...e.issues[0].path.map((p) => p.toString())],
229
+ code: e.issues[0].code,
230
+ message: e.issues[0].message,
231
+ received: JSON.stringify(argv[0]),
232
+ });
233
+ }
234
+ throw e;
235
+ }
236
+ }
237
+ }
238
+ exports.MassargNumber = MassargNumber;
239
+ /**
240
+ * An option that can be passed to a command.
241
+ *
242
+ * A flag is an option that is either present or not. It can be used to toggle
243
+ * a boolean value, or to indicate that a command should be run in a different
244
+ * mode.
245
+ *
246
+ * A flag can be negated by prefixing it with `no-`. For example, `--no-verbose`,
247
+ * or by prefixing the alias with `^` instead of `-`. This is configurable via the command's
248
+ * configuration.
249
+ *
250
+ * @example
251
+ * ```ts
252
+ * massarg.flag({
253
+ * name: 'verbose',
254
+ * aliases: ['v'],
255
+ * description: 'Enable verbose logging',
256
+ * defaultValue: false,
257
+ * })
258
+ * ```
259
+ */
260
+ class MassargFlag extends MassargOption {
261
+ constructor(options) {
262
+ super({
263
+ ...options,
264
+ parse: () => true,
265
+ });
266
+ }
267
+ _parseDetails(argv) {
268
+ try {
269
+ const isNegation = argv[0]?.startsWith(NEGATE_SHORT_PREFIX) || argv[0]?.startsWith(NEGATE_FULL_PREFIX);
270
+ if (!this._match(argv[0])) {
271
+ throw new error_1.ParseError({
272
+ path: [this.name],
273
+ code: 'invalid_option',
274
+ message: `Expected option ${this.name}`,
275
+ received: JSON.stringify(argv[0]),
276
+ });
277
+ }
278
+ argv.shift();
279
+ if (isNegation) {
280
+ return { key: this.name, value: false, argv };
281
+ }
282
+ return { key: this.name, value: true, argv };
283
+ }
284
+ catch (e) {
285
+ if ((0, error_1.isZodError)(e)) {
286
+ throw new error_1.ParseError({
287
+ path: [this.name, ...e.issues[0].path.map((p) => p.toString())],
288
+ code: e.issues[0].code,
289
+ message: e.issues[0].message,
290
+ });
291
+ }
292
+ throw e;
293
+ }
294
+ }
295
+ }
296
+ exports.MassargFlag = MassargFlag;
297
+ class MassargHelpFlag extends MassargFlag {
298
+ constructor(config = {}) {
299
+ super({
300
+ name: 'help',
301
+ description: 'Show this help message',
302
+ aliases: ['h'],
303
+ ...config,
304
+ });
305
+ }
306
+ }
307
+ exports.MassargHelpFlag = MassargHelpFlag;
308
+ //# sourceMappingURL=option.js.map
package/option.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"option.js","sourceRoot":"","sources":["../src/option.ts"],"names":[],"mappings":";;;AAAA,6BAAuB;AACvB,mCAAgD;AAChD,mCAAqC;AAG9B,MAAM,YAAY,GAAG,CAC1B,IAA2B,EAC3B,EAAE,CACF,OAAC,CAAC,MAAM,CAAC;IACP,yBAAyB;IACzB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;IAChB,8DAA8D;IAC9D,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE;IACvB,kCAAkC;IAClC,YAAY,EAAE,OAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IAChC,oFAAoF;IACpF,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE;IAC3B;;;OAGG;IACH,KAAK,EAAE,OAAC,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,OAAC,CAAC,MAAM,EAAE,EAAE,OAAC,CAAC,GAAG,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,EAEnE;IAC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