diff --git a/src/args.ts b/src/args.ts index d764cd9..3ad11e3 100644 --- a/src/args.ts +++ b/src/args.ts @@ -7,6 +7,7 @@ export function parseArgs(rawArgs: string[], argsDef: ArgsDef): ParsedArgs { const parseOptions = { boolean: [] as string[], string: [] as string[], + mixed: [] as string[], alias: {} as Record, default: {} as Record, }; @@ -17,7 +18,11 @@ export function parseArgs(rawArgs: string[], argsDef: ArgsDef): ParsedArgs { if (arg.type === "positional") { continue; } - parseOptions[arg.type || "boolean"].push(arg.name); + if (arg.type === "string") { + parseOptions.string.push(arg.name); + } else if (arg.type === "boolean") { + parseOptions.boolean.push(arg.name); + } if (arg.default !== undefined) { parseOptions.default[arg.name] = arg.default; } diff --git a/src/types.ts b/src/types.ts index 24974a6..8ea8e04 100644 --- a/src/types.ts +++ b/src/types.ts @@ -20,7 +20,7 @@ export type Arg = ArgDef & { name: string; alias: string[] }; export type ParsedArgs = { _: string[] } & Record< { [K in keyof T]: T[K] extends { type: "positional" } ? K : never }[keyof T], - string | boolean + string > & Record< { @@ -33,6 +33,12 @@ export type ParsedArgs = { _: string[] } & Record< [K in keyof T]: T[K] extends { type: "boolean" } ? K : never; }[keyof T], boolean + > & + Record< + { + [K in keyof T]: T[K] extends {} ? K : never; + }[keyof T], + string | boolean >; // ----- Command -----