massarg 2.0.0-pre.1 → 2.0.0-pre.10

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/command.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { z } from 'zod';
2
2
  import { HelpConfig } from './help';
3
- import { MassargOption, MassargFlag, OptionConfig, TypedOptionConfig } from './option';
3
+ import { MassargOption, MassargFlag, TypedOptionConfig, Prefixes, FlagConfig } from './option';
4
4
  import { DeepRequired } from './utils';
5
5
  import { MassargExample, ExampleConfig } from './example';
6
- export declare const CommandConfig: <RunArgs extends z.ZodType<any, z.ZodTypeDef, any>>(args: RunArgs) => z.ZodObject<{
6
+ export declare const CommandConfig: <RunArgs extends ArgsObject = ArgsObject>(args: z.ZodType<RunArgs, z.ZodTypeDef, RunArgs>) => z.ZodObject<{
7
7
  /** Command name */
8
8
  name: z.ZodString;
9
9
  /** Command description, displayed in the help output */
@@ -14,21 +14,37 @@ export declare const CommandConfig: <RunArgs extends z.ZodType<any, z.ZodTypeDef
14
14
  * Function used when invoking this command. It receives the parsed options and the primary
15
15
  * instance of Massarg used to invoke this command (the top-level instance)
16
16
  */
17
- run: z.ZodType<Runner<z.TypeOf<RunArgs>>, z.ZodTypeDef, Runner<z.TypeOf<RunArgs>>>;
17
+ run: z.ZodType<Runner<RunArgs>, z.ZodTypeDef, Runner<RunArgs>>;
18
+ /** Prefix of options understood by this command */
19
+ optionPrefix: z.ZodOptional<z.ZodDefault<z.ZodString>>;
20
+ /** Prefix of negated flags understood by this command */
21
+ negateFlagPrefix: z.ZodOptional<z.ZodDefault<z.ZodString>>;
22
+ /** Prefix of aliases of options understood by this command */
23
+ optionAliasPrefix: z.ZodOptional<z.ZodDefault<z.ZodString>>;
24
+ /** Prefix of aliases of negated flags understood by this command */
25
+ negateAliasPrefix: z.ZodOptional<z.ZodDefault<z.ZodString>>;
18
26
  }, "strip", z.ZodTypeAny, {
19
- description: string;
20
27
  name: string;
21
- run: Runner<z.TypeOf<RunArgs>>;
28
+ description: string;
29
+ run: Runner<RunArgs>;
22
30
  aliases?: string[] | undefined;
31
+ optionPrefix?: string | undefined;
32
+ negateFlagPrefix?: string | undefined;
33
+ optionAliasPrefix?: string | undefined;
34
+ negateAliasPrefix?: string | undefined;
23
35
  }, {
24
- description: string;
25
36
  name: string;
26
- run: Runner<z.TypeOf<RunArgs>>;
37
+ description: string;
38
+ run: Runner<RunArgs>;
27
39
  aliases?: string[] | undefined;
40
+ optionPrefix?: string | undefined;
41
+ negateFlagPrefix?: string | undefined;
42
+ optionAliasPrefix?: string | undefined;
43
+ negateAliasPrefix?: string | undefined;
28
44
  }>;
29
- export type CommandConfig<T = unknown> = z.infer<ReturnType<typeof CommandConfig<z.ZodType<T>>>>;
30
- export type ArgsObject = Record<string, unknown>;
31
- export type Runner<Args extends ArgsObject> = <A extends ArgsObject = Args>(options: A, instance: MassargCommand<A>) => Promise<void> | void;
45
+ export type CommandConfig<RunArgs extends ArgsObject = ArgsObject> = z.infer<ReturnType<typeof CommandConfig<RunArgs>>>;
46
+ export type ArgsObject = Record<string | number | symbol, any>;
47
+ export type Runner<Args extends ArgsObject> = (options: Args, instance: MassargCommand<Args>) => Promise<void> | void;
32
48
  /**
33
49
  * A command is a named function that can be invoked with a set of options.
34
50
  *
@@ -48,7 +64,7 @@ export type Runner<Args extends ArgsObject> = <A extends ArgsObject = Args>(opti
48
64
  * })
49
65
  * ```
50
66
  */
51
- export declare class MassargCommand<Args extends ArgsObject = ArgsObject> {
67
+ export declare class MassargCommand<Args extends ArgsObject = ArgsObject> implements Omit<CommandConfig<Args>, 'run'> {
52
68
  name: string;
53
69
  description: string;
54
70
  aliases: string[];
@@ -59,7 +75,13 @@ export declare class MassargCommand<Args extends ArgsObject = ArgsObject> {
59
75
  args: Partial<Args>;
60
76
  private _helpConfig;
61
77
  parent?: MassargCommand<any>;
78
+ optionPrefix: string;
79
+ negateFlagPrefix: string;
80
+ optionAliasPrefix: string;
81
+ negateAliasPrefix: string;
62
82
  constructor(options: CommandConfig<Args>, parent?: MassargCommand<any>);
83
+ get optionPrefixes(): Prefixes;
84
+ private getPrefixes;
63
85
  get helpConfig(): DeepRequired<HelpConfig>;
64
86
  /**
65
87
  * Add a sub-command to this command.
@@ -70,8 +92,8 @@ export declare class MassargCommand<Args extends ArgsObject = ArgsObject> {
70
92
  * While options are not inherited, they will be passed from any parent commands
71
93
  * to the sub-command when invoked.
72
94
  */
73
- command<A extends ArgsObject = Args>(config: CommandConfig<A>): MassargCommand<Args>;
74
- command<A extends ArgsObject = Args>(config: MassargCommand<A>): MassargCommand<Args>;
95
+ command<A extends ArgsObject = Args>(config: CommandConfig<A>): MassargCommand<Args & A>;
96
+ command<A extends ArgsObject = Args>(config: MassargCommand<A>): MassargCommand<Args & A>;
75
97
  /**
76
98
  * Adds a flag to this command.
77
99
  *
@@ -83,7 +105,7 @@ export declare class MassargCommand<Args extends ArgsObject = ArgsObject> {
83
105
  * or by prefixing the alias with `^` instead of `-`. This is configurable via the command's
84
106
  * configuration.
85
107
  */
86
- flag(config: Omit<OptionConfig<boolean>, 'parse' | 'isDefault'>): MassargCommand<Args>;
108
+ flag(config: FlagConfig): MassargCommand<Args>;
87
109
  flag(config: MassargFlag): MassargCommand<Args>;
88
110
  /**
89
111
  * Adds an option to this command.
@@ -98,8 +120,10 @@ export declare class MassargCommand<Args extends ArgsObject = ArgsObject> {
98
120
  * value passed to the command. This is useful if you want to parse a string
99
121
  * into a more complex type, or if you want to validate the value.
100
122
  */
101
- option<T = string>(config: MassargOption<T>): MassargCommand<Args>;
102
- option<T = string>(config: TypedOptionConfig<T>): MassargCommand<Args>;
123
+ option<T = string, A extends ArgsObject = Args>(config: MassargOption<T, A>): MassargCommand<Args>;
124
+ option<T = string, A extends ArgsObject = Args>(config: TypedOptionConfig<T, A>): MassargCommand<Args>;
125
+ private assertNotDuplicate;
126
+ private assertOnlyOneDefault;
103
127
  /**
104
128
  * Adds an example to this command.
105
129
  *
@@ -125,7 +149,7 @@ export declare class MassargCommand<Args extends ArgsObject = ArgsObject> {
125
149
  *
126
150
  * If none is provided, help will be printed.
127
151
  */
128
- main<A extends ArgsObject = Args>(run: Runner<A>): MassargCommand<Args>;
152
+ main(run: Runner<Args>): MassargCommand<Args>;
129
153
  /**
130
154
  * Parse the given arguments and run the command or sub-commands along with the given options
131
155
  * and flags.
@@ -133,11 +157,13 @@ export declare class MassargCommand<Args extends ArgsObject = ArgsObject> {
133
157
  * To parse the arguments without running any commands and only get the output args,
134
158
  * use `getArgs` instead.
135
159
  */
136
- parse(argv: string[], args?: Partial<Args>, parent?: MassargCommand<Args>): Promise<void> | void;
160
+ parse(argv?: string[], args?: Partial<Args>, parent?: MassargCommand<Args>): Promise<void> | void;
161
+ private printError;
137
162
  private parseOption;
138
163
  /** Parse the given arguments and return the output args. */
139
164
  getArgs(argv: string[], __args?: Partial<Args>, parent?: MassargCommand<any>, parseCommands?: false): Promise<void> | void;
140
165
  getArgs(argv: string[], __args?: Partial<Args>, parent?: MassargCommand<any>, parseCommands?: true): Args;
166
+ private assertRequired;
141
167
  /**
142
168
  * Generate the help output for this command, and return it as a string.
143
169
  */
@@ -147,7 +173,11 @@ export declare class MassargCommand<Args extends ArgsObject = ArgsObject> {
147
173
  */
148
174
  printHelp(): void;
149
175
  }
150
- export declare class MassargHelpCommand<T extends ArgsObject = ArgsObject> extends MassargCommand<T> {
176
+ export declare class MassargHelpCommand<T extends {
177
+ command?: string;
178
+ } = {
179
+ command?: string;
180
+ }> extends MassargCommand<T> {
151
181
  constructor(config?: Partial<Omit<CommandConfig<T>, 'run'>>);
152
182
  }
153
183
  //# sourceMappingURL=command.d.ts.map
package/command.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAAqB,UAAU,EAAiB,MAAM,QAAQ,CAAA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./utils");
9
9
  const example_1 = require("./example");
10
+ const style_1 = require("./style");
10
11
  const CommandConfig = (args) => zod_1.z.object({
11
12
  /** Command name */
12
13
  name: zod_1.z.string(),
@@ -22,6 +23,14 @@ const CommandConfig = (args) => zod_1.z.object({
22
23
  .function()
23
24
  .args(args, zod_1.z.any())
24
25
  .returns(zod_1.z.union([zod_1.z.promise(zod_1.z.void()), zod_1.z.void()])),
26
+ /** Prefix of options understood by this command */
27
+ optionPrefix: zod_1.z.string().default(option_1.OPT_FULL_PREFIX).optional(),
28
+ /** Prefix of negated flags understood by this command */
29
+ negateFlagPrefix: zod_1.z.string().default(option_1.NEGATE_FULL_PREFIX).optional(),
30
+ /** Prefix of aliases of options understood by this command */
31
+ optionAliasPrefix: zod_1.z.string().default(option_1.OPT_SHORT_PREFIX).optional(),
32
+ /** Prefix of aliases of negated flags understood by this command */
33
+ negateAliasPrefix: zod_1.z.string().default(option_1.NEGATE_SHORT_PREFIX).optional(),
25
34
  });
26
35
  exports.CommandConfig = CommandConfig;
27
36
  /**
@@ -49,6 +58,10 @@ class MassargCommand {
49
58
  this.options = [];
50
59
  this.examples = [];
51
60
  this.args = {};
61
+ this.optionPrefix = option_1.OPT_FULL_PREFIX;
62
+ this.negateFlagPrefix = option_1.NEGATE_FULL_PREFIX;
63
+ this.optionAliasPrefix = option_1.OPT_SHORT_PREFIX;
64
+ this.negateAliasPrefix = option_1.NEGATE_SHORT_PREFIX;
52
65
  (0, exports.CommandConfig)(zod_1.z.any()).parse(options);
53
66
  this.name = options.name;
54
67
  this.description = options.description;
@@ -56,12 +69,35 @@ class MassargCommand {
56
69
  this._run = options.run;
57
70
  this._helpConfig = {};
58
71
  this.parent = parent;
72
+ // TODO mix these with help config
73
+ this.optionPrefix = options.optionPrefix ?? this.optionPrefix;
74
+ this.negateFlagPrefix = options.negateFlagPrefix ?? this.negateFlagPrefix;
75
+ this.optionAliasPrefix = options.optionAliasPrefix ?? this.optionAliasPrefix;
76
+ this.negateAliasPrefix = options.negateAliasPrefix ?? this.negateAliasPrefix;
77
+ }
78
+ get optionPrefixes() {
79
+ return this.getPrefixes();
80
+ }
81
+ getPrefixes() {
82
+ return {
83
+ optionPrefix: this.optionPrefix,
84
+ aliasPrefix: this.optionAliasPrefix,
85
+ negateFlagPrefix: this.negateFlagPrefix,
86
+ negateAliasPrefix: this.negateAliasPrefix,
87
+ };
59
88
  }
60
89
  get helpConfig() {
61
90
  if (this.parent) {
62
91
  return (0, utils_1.deepMerge)(this.parent.helpConfig, this._helpConfig);
63
92
  }
64
- return (0, utils_1.deepMerge)(help_1.defaultHelpConfig, this._helpConfig);
93
+ return (0, utils_1.deepMerge)(help_1.defaultHelpConfig, (0, utils_1.deepMerge)({
94
+ optionOptions: {
95
+ namePrefix: this.optionPrefix,
96
+ aliasPrefix: this.optionAliasPrefix,
97
+ negatePrefix: this.negateFlagPrefix,
98
+ negateAliasPrefix: this.negateAliasPrefix,
99
+ },
100
+ }, this._helpConfig));
65
101
  }
66
102
  command(config) {
67
103
  try {
@@ -80,75 +116,88 @@ class MassargCommand {
80
116
  }
81
117
  catch (e) {
82
118
  if ((0, error_1.isZodError)(e)) {
83
- throw new error_1.ValidationError({
119
+ e = new error_1.ValidationError({
84
120
  path: [this.name, config.name, ...e.issues[0].path.map((p) => p.toString())],
85
121
  code: e.issues[0].code,
86
122
  message: e.issues[0].message,
87
123
  });
88
124
  }
125
+ this.printError(e);
89
126
  throw e;
90
127
  }
91
128
  }
92
129
  flag(config) {
93
130
  try {
94
131
  const flag = config instanceof option_1.MassargFlag ? config : new option_1.MassargFlag(config);
95
- const existing = this.options.find((c) => c.name === flag.name);
96
- if (existing) {
97
- throw new error_1.ValidationError({
98
- code: 'duplicate_flag',
99
- message: `Flag "${flag.name}" already exists`,
100
- path: [this.name, flag.name],
101
- });
102
- }
132
+ this.assertNotDuplicate(flag, 'flag');
103
133
  this.options.push(flag);
104
134
  return this;
105
135
  }
106
136
  catch (e) {
107
137
  if ((0, error_1.isZodError)(e)) {
108
- throw new error_1.ValidationError({
138
+ e = new error_1.ValidationError({
109
139
  path: [this.name, config.name, ...e.issues[0].path.map((p) => p.toString())],
110
140
  code: e.issues[0].code,
111
141
  message: e.issues[0].message,
112
142
  });
113
143
  }
144
+ this.printError(e);
114
145
  throw e;
115
146
  }
116
147
  }
117
148
  option(config) {
118
149
  try {
119
- const option = config instanceof option_1.MassargOption ? config : option_1.MassargOption.fromTypedConfig(config);
120
- const existing = this.options.find((c) => c.name === option.name);
121
- if (existing) {
122
- throw new error_1.ValidationError({
123
- code: 'duplicate_option',
124
- message: `Option "${option.name}" already exists`,
125
- path: [this.name, option.name],
126
- });
127
- }
128
- if (option.isDefault) {
129
- const defaultOption = this.options.find((o) => o.isDefault);
130
- if (defaultOption) {
131
- throw new error_1.ValidationError({
132
- code: 'duplicate_default_option',
133
- message: `Option "${option.name}" cannot be set as default because option "${defaultOption.name}" is already set as default`,
134
- path: [this.name, option.name],
135
- });
136
- }
137
- }
150
+ const option = config instanceof option_1.MassargOption
151
+ ? config
152
+ : option_1.MassargOption.fromTypedConfig(config);
153
+ this.assertNotDuplicate(option, 'option');
154
+ this.assertOnlyOneDefault(option);
138
155
  this.options.push(option);
139
156
  return this;
140
157
  }
141
158
  catch (e) {
142
159
  if ((0, error_1.isZodError)(e)) {
143
- throw new error_1.ValidationError({
160
+ e = new error_1.ValidationError({
144
161
  path: [this.name, config.name, ...e.issues[0].path.map((p) => p.toString())],
145
162
  code: e.issues[0].code,
146
163
  message: e.issues[0].message,
147
164
  });
148
165
  }
166
+ this.printError(e);
149
167
  throw e;
150
168
  }
151
169
  }
170
+ assertNotDuplicate(option, type) {
171
+ const existingName = this.options.find((c) => c.name === option.name);
172
+ if (existingName) {
173
+ throw new error_1.ValidationError({
174
+ code: `duplicate_${type}_name`,
175
+ message: `${(0, utils_1.capitalize)(type)} name "${existingName.name}" already exists`,
176
+ path: [this.name, option.name],
177
+ });
178
+ }
179
+ const existingAlias = this.options.find((c) => c.aliases.some((a) => option.aliases.includes(a)));
180
+ if (existingAlias) {
181
+ const alias = option.aliases.find((a) => existingAlias.aliases.includes(a));
182
+ throw new error_1.ValidationError({
183
+ code: 'duplicate_option_alias',
184
+ message: `Option alias "${alias}" already exists on option "${existingAlias.name}"`,
185
+ path: [this.name, option.name],
186
+ });
187
+ }
188
+ }
189
+ assertOnlyOneDefault(option) {
190
+ if (option.isDefault) {
191
+ const defaultOption = this.options.find((o) => o.isDefault);
192
+ if (defaultOption) {
193
+ throw new error_1.ValidationError({
194
+ code: 'duplicate_default_option',
195
+ message: `Option "${option.name}" cannot be set as default because option "${defaultOption.name}" is already set as default`,
196
+ path: [this.name, option.name],
197
+ });
198
+ }
199
+ }
200
+ }
152
201
  /**
153
202
  * Adds an example to this command.
154
203
  *
@@ -172,11 +221,12 @@ class MassargCommand {
172
221
  */
173
222
  help(config) {
174
223
  this._helpConfig = help_1.HelpConfig.parse(config);
224
+ let ret = this;
175
225
  if (this.helpConfig.bindCommand) {
176
- this.command(new MassargHelpCommand());
226
+ ret = ret.command(new MassargHelpCommand());
177
227
  }
178
228
  if (this.helpConfig.bindOption) {
179
- this.option(new option_1.MassargHelpFlag());
229
+ ret = ret.option(new option_1.MassargHelpFlag());
180
230
  }
181
231
  return this;
182
232
  }
@@ -197,71 +247,114 @@ class MassargCommand {
197
247
  * To parse the arguments without running any commands and only get the output args,
198
248
  * use `getArgs` instead.
199
249
  */
200
- parse(argv, args, parent) {
201
- this.getArgs(argv, args, parent, true);
250
+ parse(argv = process.argv.slice(2), args, parent) {
251
+ try {
252
+ this.getArgs(argv, args, parent, true);
253
+ }
254
+ catch (e) {
255
+ this.printError(e);
256
+ }
257
+ }
258
+ printError(e) {
259
+ const message = (0, utils_1.getErrorMessage)(e);
260
+ console.error((0, style_1.format)(message, { color: 'red' }));
202
261
  }
203
262
  parseOption(arg, argv) {
204
- const option = this.options.find((o) => o._match(arg));
263
+ const prefixes = { ...this.optionPrefixes };
264
+ const option = this.options.find((o) => o.isMatch(arg, prefixes));
205
265
  if (!option) {
206
266
  throw new error_1.ValidationError({
207
- path: [option_1.MassargOption.getName(arg)],
267
+ path: [option_1.MassargOption.findNameInArg(arg, prefixes)],
208
268
  code: 'unknown_option',
209
269
  message: 'Unknown option',
210
270
  });
211
271
  }
212
- const res = option._parseDetails([arg, ...argv]);
272
+ const res = option.parseDetails([arg, ...argv], { ...this.args }, prefixes);
213
273
  this.args[res.key] = (0, utils_1.setOrPush)(res.value, this.args[res.key], option.isArray);
214
274
  return res.argv;
215
275
  }
216
276
  getArgs(argv, args, parent, parseCommands = false) {
217
- let _args = { ...this.args, ...args };
218
- let _argv = [...argv];
219
- const _a = this.args;
220
- // fill defaults
221
- for (const option of this.options) {
222
- if (option.defaultValue !== undefined && _a[option.name] === undefined) {
223
- _args[option.name] = option.defaultValue;
224
- }
225
- }
226
- // parse options
227
- while (_argv.length) {
228
- const arg = _argv.shift();
229
- // make sure option exists
230
- const found = this.options.some((o) => o._isOption(arg));
231
- if (found) {
232
- _argv = this.parseOption(arg, _argv);
233
- _args = { ..._args, ...this.args };
234
- continue;
277
+ try {
278
+ let _args = { ...this.args, ...args };
279
+ let _argv = [...argv];
280
+ const _a = this.args;
281
+ // fill defaults
282
+ for (const option of this.options) {
283
+ if (option.defaultValue !== undefined && _a[option.name] === undefined) {
284
+ _args[option.getOutputName()] = option.defaultValue;
285
+ }
235
286
  }
236
- // if not, try see if it's a command
237
- const command = this.commands.find((c) => c.name === arg || c.aliases.includes(arg));
238
- if (command) {
239
- // this is dry run, just exit
240
- if (!parseCommands) {
241
- break;
287
+ // parse options
288
+ while (_argv.length) {
289
+ const arg = _argv.shift();
290
+ // make sure option exists
291
+ const found = this.options.find((o) => o.isMatch(arg, this.optionPrefixes));
292
+ if (found) {
293
+ if (this.helpConfig.bindOption && found.name === 'help') {
294
+ if (parseCommands) {
295
+ this.printHelp();
296
+ return;
297
+ }
298
+ return this.args;
299
+ }
300
+ _argv = this.parseOption(arg, _argv);
301
+ _args = { ..._args, ...this.args };
302
+ continue;
303
+ }
304
+ // if not, try see if it's a command
305
+ const command = this.commands.find((c) => c.name === arg || c.aliases.includes(arg));
306
+ if (command) {
307
+ // this is dry run, just exit
308
+ if (!parseCommands) {
309
+ return command.getArgs(_argv, this.args, parent ?? this, false);
310
+ // break
311
+ }
312
+ // this is real run, parse command, pass unparsed args
313
+ return command.parse(_argv, this.args, parent ?? this);
242
314
  }
243
- // this is real run, parse command, pass unparsed args
244
- return command.parse(_argv, this.args, parent ?? this);
315
+ // default option - passes arg value even without flag name
316
+ const defaultOption = this.options.find((o) => o.isDefault);
317
+ if (defaultOption) {
318
+ this.parseOption(`--${defaultOption.name}`, [arg]);
319
+ continue;
320
+ }
321
+ // not parsed by any step, add to extra key
322
+ _a.extra ??= [];
323
+ _a.extra.push(arg);
245
324
  }
246
- // default option - passes arg value even without flag name
247
- const defaultOption = this.options.find((o) => o.isDefault);
248
- if (defaultOption) {
249
- _argv = this.parseOption(`--${defaultOption.name}`, [arg, ..._argv]);
250
- continue;
325
+ // merge args
326
+ this.args = { ...this.args, ..._args };
327
+ this.assertRequired();
328
+ // dry run, just exit
329
+ if (!parseCommands) {
330
+ return this.args;
331
+ }
332
+ // no sub command found, run main command
333
+ if (this._run) {
334
+ this._run(this.args, parent ?? this);
251
335
  }
252
- // not parsed by any step, add to extra key
253
- _a.extra ??= [];
254
- _a.extra.push(arg);
255
336
  }
256
- // merge args
257
- this.args = { ...this.args, ..._args };
258
- // dry run, just exit
259
- if (!parseCommands) {
260
- return this.args;
337
+ catch (e) {
338
+ if ((0, error_1.isZodError)(e)) {
339
+ e = new error_1.ValidationError({
340
+ path: [this.name, ...e.issues[0].path.map((p) => p.toString())],
341
+ code: e.issues[0].code,
342
+ message: e.issues[0].message,
343
+ });
344
+ }
345
+ throw e;
261
346
  }
262
- // no sub command found, run main command
263
- if (this._run) {
264
- this._run(this.args, parent ?? this);
347
+ }
348
+ assertRequired() {
349
+ const required = this.options.filter((o) => o.isRequired);
350
+ const missing = required.filter((o) => this.args[o.getOutputName()] === undefined);
351
+ if (missing.length) {
352
+ const plural = missing.length > 1 ? 's' : '';
353
+ throw new error_1.ValidationError({
354
+ code: 'missing_required_options',
355
+ message: `Missing required option${plural}: ${missing.map((o) => o.name).join(', ')}`,
356
+ path: [this.name],
357
+ });
265
358
  }
266
359
  }
267
360
  /**
@@ -280,11 +373,10 @@ class MassargCommand {
280
373
  exports.MassargCommand = MassargCommand;
281
374
  class MassargHelpCommand extends MassargCommand {
282
375
  constructor(config = {}) {
283
- super({
376
+ const _config = (0, exports.CommandConfig)(zod_1.z.any()).parse({
284
377
  name: 'help',
285
378
  aliases: ['h'],
286
- description: 'Print help for this command, or a subcommand if specified',
287
- // argsHint: "[command]",
379
+ description: 'Print help for this command, or a sub-command if specified',
288
380
  run: (args, parent) => {
289
381
  if (args.command) {
290
382
  const command = parent.commands.find((c) => c.name === args.command);
@@ -305,6 +397,7 @@ class MassargHelpCommand extends MassargCommand {
305
397
  },
306
398
  ...config,
307
399
  });
400
+ super(_config);
308
401
  this.option({
309
402
  name: 'command',
310
403
  aliases: ['c'],
package/command.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"command.js","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":";;;AAAA,6BAAuB;AACvB,mCAAiE;AACjE,iCAAqE;AACrE,qCAMiB;AACjB,mCAA4D;AAC5D,uCAAyD;AAElD,MAAM,aAAa,GAAG,CAA4B,IAAa,EAAE,EAAE,CACxE,OAAC,CAAC,MAAM,CAAC;IACP,mBAAmB;IACnB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;IAChB,wDAAwD;IACxD,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE;IACvB,sBAAsB;IACtB,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE;IACtC;;;OAGG;IACH,GAAG,EAAE,OAAC;SACH,QAAQ,EAAE;SACV,IAAI,CAAC,IAAI,EAAE,OAAC,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AAI,CAAC,MAAM,CAAC;YACV,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,CAAC,GAAG,CAAC;YACd,WAAW,EAAE,2BAA2B;YACxC,SAAS,EAAE,IAAI;SAChB,CAAC,CAAA;IACJ,CAAC;CACF;AAnCD,gDAmCC"}
package/error.d.ts CHANGED
@@ -1,4 +1,9 @@
1
1
  import { z } from 'zod';
2
+ export type ValidationErrorOptions = {
3
+ path: string[];
4
+ code: string;
5
+ message: string;
6
+ };
2
7
  /** This error is thrown when a validation fails. */
3
8
  export declare class ValidationError extends Error {
4
9
  /** The path to the value that failed validation. */
@@ -7,12 +12,14 @@ export declare class ValidationError extends Error {
7
12
  code: string;
8
13
  /** The error message. */
9
14
  message: string;
10
- constructor({ path, code, message }: {
11
- path: string[];
12
- code: string;
13
- message: string;
14
- });
15
+ constructor({ path, code, message }: ValidationErrorOptions);
15
16
  }
17
+ export type ParseErrorOptions = {
18
+ path: string[];
19
+ code: string;
20
+ message: string;
21
+ received?: unknown;
22
+ };
16
23
  /** This error is thrown when a parse fails on an option value. */
17
24
  export declare class ParseError extends Error {
18
25
  /** The path to the value that failed parsing. */
@@ -23,12 +30,7 @@ export declare class ParseError extends Error {
23
30
  message: string;
24
31
  /** The value that failed parsing. */
25
32
  received: unknown;
26
- constructor({ path, code, message, received, }: {
27
- path: string[];
28
- code: string;
29
- message: string;
30
- received?: unknown;
31
- });
33
+ constructor({ path, code, message, received }: ParseErrorOptions);
32
34
  }
33
35
  export declare function isZodError(e: unknown): e is z.ZodError;
34
36
  //# sourceMappingURL=error.d.ts.map