Skip to content

Commit 3cbe296

Browse files
committed
types
1 parent 3440a07 commit 3cbe296

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/citty.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineCommand } from "citty";
1+
import { ArgDef, defineCommand } from "citty";
22
import * as zsh from "../zsh";
33
import * as bash from "../bash";
44
import * as fish from "../fish";
@@ -40,12 +40,16 @@ export default async function tab(instance: CommandDef) {
4040
//TODO: resolver function
4141
for (const [cmd, resolvableConfig] of Object.entries(subCommands)) {
4242
const config = typeof resolvableConfig === "function" ? await resolvableConfig() : await resolvableConfig
43-
completion.addCommand(cmd, config.meta?.description, config.run);
44-
if (cmd.args) {
45-
for (const [argName, argConfig] of Object.entries(cmd.args)) {
46-
const conf = argConfig;
43+
const meta = typeof config.meta === "function" ? await config.meta() : await config.meta;
44+
if (!meta || typeof meta?.description !== "string") {
45+
throw new Error("Invalid meta or missing description.");
46+
}
47+
completion.addCommand(cmd, meta.description, config.run ?? (() => { }));
48+
if (config.args) {
49+
for (const [argName, argConfig] of Object.entries(config.args)) {
50+
const conf = argConfig as ArgDef;
4751
completion.addOption(
48-
cmd.meta.name,
52+
meta.name!,
4953
`--${argName}`,
5054
conf.description ?? "",
5155
() => { }

0 commit comments

Comments
 (0)