File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed
Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -78,6 +78,11 @@ export default async function tab(
7878 const targetCommand = isRootCommand ? t : command ;
7979 if ( targetCommand ) {
8080 const handler = commandCompletionConfig ?. options ?. [ argName ] ;
81+
82+ // Check if option takes a value (has <> or [] in rawName, or is marked as required)
83+ const takesValue =
84+ option . required || / < [ ^ > ] + > | \[ [ ^ \] ] + \] / . test ( option . rawName ) ;
85+
8186 if ( handler ) {
8287 // Has custom handler → value option
8388 if ( shortFlag ) {
@@ -90,8 +95,24 @@ export default async function tab(
9095 } else {
9196 targetCommand . option ( argName , option . description || '' , handler ) ;
9297 }
98+ } else if ( takesValue ) {
99+ // Takes value but no custom handler → value option with no completions
100+ if ( shortFlag ) {
101+ targetCommand . option (
102+ argName ,
103+ option . description || '' ,
104+ async ( ) => [ ] , // Empty completions
105+ shortFlag
106+ ) ;
107+ } else {
108+ targetCommand . option (
109+ argName ,
110+ option . description || '' ,
111+ async ( ) => [ ]
112+ ) ;
113+ }
93114 } else {
94- // No custom handler → boolean flag
115+ // No custom handler and doesn't take value → boolean flag
95116 if ( shortFlag ) {
96117 targetCommand . option ( argName , option . description || '' , shortFlag ) ;
97118 } else {
You can’t perform that action at this time.
0 commit comments