Skip to content

Commit

Permalink
feat: more descriptive transform errors on execution
Browse files Browse the repository at this point in the history
  • Loading branch information
paradoxuum committed Aug 3, 2024
1 parent d08a788 commit d04a31b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/core/src/shared/core/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,13 @@ export class ExecutableCommand extends BaseCommand {
if (argInputs.isEmpty()) {
if (arg.options.optional) break;
return TransformResult.err(
`Missing required argument: <b>${arg.options.name}</b>`,
`Missing required argument: ${arg.options.name}`,
);
}

if (isNum && argInputs.size() < numArgs) {
return TransformResult.err(
`Argument <b>${arg.options.name}</b> requires ${numArgs} argument(s), but only ${argInputs.size()} were provided`,
`Argument '${arg.options.name}' requires ${numArgs} argument(s), but only ${argInputs.size()} were provided`,
);
}

Expand All @@ -180,7 +180,11 @@ export class ExecutableCommand extends BaseCommand {
);
}

if (!result.ok) return TransformResult.err(result.value);
if (!result.ok) {
return TransformResult.err(
`[argument '${arg.options.name}'] ${result.value}`,
);
}
argValues[i] = result.value;
}

Expand Down

0 comments on commit d04a31b

Please sign in to comment.