@@ -15,6 +15,9 @@ const quotedProcessExecArgs = process.execArgv.map(quoteIfNeeded);
1515
1616const x = `${ quotedExecPath } ${ quotedProcessExecArgs . join ( ' ' ) } ${ quotedProcessArgs [ 0 ] } ` ;
1717
18+ // Regex to detect if an option takes a value (has <required> or [optional] parameters)
19+ const VALUE_OPTION_RE = / < [ ^ > ] + > | \[ [ ^ \] ] + \] / ;
20+
1821function quoteIfNeeded ( path : string ) : string {
1922 return path . includes ( ' ' ) ? `'${ path } '` : path ;
2023}
@@ -81,10 +84,9 @@ export default async function tab(
8184
8285 // Check if option takes a value (has <> or [] in rawName, or is marked as required)
8386 const takesValue =
84- option . required || / < [ ^ > ] + > | \[ [ ^ \] ] + \] / . test ( option . rawName ) ;
87+ option . required || VALUE_OPTION_RE . test ( option . rawName ) ;
8588
8689 if ( handler ) {
87- // Has custom handler → value option
8890 if ( shortFlag ) {
8991 targetCommand . option (
9092 argName ,
@@ -96,7 +98,7 @@ export default async function tab(
9698 targetCommand . option ( argName , option . description || '' , handler ) ;
9799 }
98100 } else if ( takesValue ) {
99- // Takes value but no custom handler → value option with no completions
101+ // Takes value but no custom handler = value option with no completions
100102 if ( shortFlag ) {
101103 targetCommand . option (
102104 argName ,
@@ -112,7 +114,7 @@ export default async function tab(
112114 ) ;
113115 }
114116 } else {
115- // No custom handler and doesn't take value → boolean flag
117+ // No custom handler and doesn't take value = boolean flag
116118 if ( shortFlag ) {
117119 targetCommand . option ( argName , option . description || '' , shortFlag ) ;
118120 } else {
0 commit comments