[READ-ONLY] Mirror of https://github.com/bombshell-dev/tab. shell autocompletions for javascript CLIs
4

Configure Feed

Select the types of activity you want to include in your feed.

fix: cac: treat options correctly (#60)

* treat options well

* update

* update

authored by

AmirHossein Sakhravi and committed by
GitHub
(Sep 26, 2025, 1:25 PM +0330) 1080e7c5 e7b53f45

+25 -2
+25 -2
src/cac.ts
··· 15 15 16 16 const x = `${quotedExecPath} ${quotedProcessExecArgs.join(' ')} ${quotedProcessArgs[0]}`; 17 17 18 + // Regex to detect if an option takes a value (has <required> or [optional] parameters) 19 + const VALUE_OPTION_RE = /<[^>]+>|\[[^\]]+\]/; 20 + 18 21 function quoteIfNeeded(path: string): string { 19 22 return path.includes(' ') ? `'${path}'` : path; 20 23 } ··· 78 81 const targetCommand = isRootCommand ? t : command; 79 82 if (targetCommand) { 80 83 const handler = commandCompletionConfig?.options?.[argName]; 84 + 85 + // Check if option takes a value (has <> or [] in rawName, or is marked as required) 86 + const takesValue = 87 + option.required || VALUE_OPTION_RE.test(option.rawName); 88 + 81 89 if (handler) { 82 - // Has custom handler → value option 83 90 if (shortFlag) { 84 91 targetCommand.option( 85 92 argName, ··· 90 97 } else { 91 98 targetCommand.option(argName, option.description || '', handler); 92 99 } 100 + } else if (takesValue) { 101 + // Takes value but no custom handler = value option with no completions 102 + if (shortFlag) { 103 + targetCommand.option( 104 + argName, 105 + option.description || '', 106 + async () => [], // Empty completions 107 + shortFlag 108 + ); 109 + } else { 110 + targetCommand.option( 111 + argName, 112 + option.description || '', 113 + async () => [] 114 + ); 115 + } 93 116 } else { 94 - // No custom handler → boolean flag 117 + // No custom handler and doesn't take value = boolean flag 95 118 if (shortFlag) { 96 119 targetCommand.option(argName, option.description || '', shortFlag); 97 120 } else {