refactor: change CommandSchema's options/flags to be Records

This commit is contained in:
2026-04-02 08:29:40 +08:00
parent f1b1741db8
commit 281cbf845d
7 changed files with 64 additions and 101 deletions
+2 -2
View File
@@ -71,7 +71,7 @@ function commandMatchesSchema(command: Command, schema: CommandSchema): boolean
return false;
}
const requiredOptions = schema.options.filter(o => o.required);
const requiredOptions = Object.values(schema.options).filter(o => o.required);
for (const opt of requiredOptions) {
const hasOption = opt.name in command.options || (opt.short && opt.short in command.options);
if (!hasOption) {
@@ -131,7 +131,7 @@ function handleGeneratorResult<T>(
ctx.state = 'invoking';
return invokeChildRule(host, yielded.rule, yielded.command, ctx as RuleContext<unknown>);
} else {
ctx.schema = parseYieldedSchema({ name: '', params: [], options: [], flags: [] });
ctx.schema = parseYieldedSchema({ name: '', params: [], options: {}, flags: {} });
ctx.state = 'yielded';
}
} else {