File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed
Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change 1- import { defineCommand } from "citty" ;
1+ import { ArgDef , defineCommand } from "citty" ;
22import * as zsh from "../zsh" ;
33import * as bash from "../bash" ;
44import * 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 ( ) => { }
You can’t perform that action at this time.
0 commit comments