[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.

update

AmirSa12 (Aug 17, 2025, 1:54 PM +0330) 7c0ad271 dae6ae7e

+41 -15
+2 -8
src/bash.ts
··· 42 42 local requestComp out directive 43 43 44 44 # Build the command to get completions 45 - # Use a more compatible approach instead of \${words[@]:1} 46 - local args="" 47 - for (( i=1; i<cword+1; i++ )); do 48 - if [[ -n "\${words[i]}" ]]; then 49 - args="$args \\"\${words[i]}\\"" 50 - fi 51 - done 52 - requestComp="${exec} complete --$args" 45 + requestComp="${exec} complete -- \${words[@]:1}" 53 46 54 47 # Add an empty parameter if the last parameter is complete 55 48 if [[ -z "$cur" ]]; then ··· 125 118 126 119 # Register completion function 127 120 complete -F __${nameForVar}_complete ${name} 121 + 128 122 `; 129 123 }
+19 -3
tests/package-manager-integration.test.ts
··· 114 114 // If we get here, syntax is valid 115 115 expect(true).toBe(true); 116 116 } catch (error) { 117 - throw new Error(`${pm} bash script has syntax errors: ${error}`); 117 + const errorMessage = 118 + error instanceof Error ? error.message : String(error); 119 + 120 + // Provide helpful error message about bash-completion dependency 121 + const helpMessage = ` 122 + ${pm} bash script has syntax errors: ${errorMessage} 123 + 124 + This might be due to missing bash-completion dependency. 125 + To fix this, install bash-completion@2: 126 + 127 + brew install bash-completion@2 128 + 129 + Then source the completion in your shell profile: 130 + echo 'source $(brew --prefix)/share/bash-completion/bash_completion' >> ~/.bashrc 131 + `; 132 + throw new Error(helpMessage); 118 133 } finally { 119 134 // Clean up 120 135 await unlink(scriptPath).catch(() => {}); ··· 125 140 const command = `pnpm tsx bin/cli.ts ${pm} bash`; 126 141 const { stdout } = await exec(command); 127 142 128 - // Check for the actual problematic bash syntax in the requestComp assignment 129 - expect(stdout).not.toMatch(/requestComp="[^"]*\$\{words\[@\]:1\}/); // Should not use ${words[@]:1} in requestComp 143 + // Check that it uses the correct ${words[@]:1} syntax (requires bash-completion@2) 144 + expect(stdout).toContain('${words[@]:1}'); // Should use ${words[@]:1} (requires bash-completion@2) 130 145 expect(stdout).toContain('complete -F'); // Should register completion properly 146 + expect(stdout).toContain('_get_comp_words_by_ref'); // Should use bash-completion functions 131 147 132 148 // Should contain package manager specific function 133 149 expect(stdout).toMatch(
+20 -4
tests/shell-integration.test.ts
··· 78 78 // If we get here, syntax is valid 79 79 expect(true).toBe(true); 80 80 } catch (error) { 81 - throw new Error(`Bash script has syntax errors: ${error}`); 81 + const errorMessage = 82 + error instanceof Error ? error.message : String(error); 83 + 84 + // Provide helpful error message about bash-completion dependency 85 + const helpMessage = ` 86 + Bash script has syntax errors: ${errorMessage} 87 + 88 + This might be due to missing bash-completion dependency. 89 + To fix this, install bash-completion@2: 90 + 91 + brew install bash-completion@2 92 + 93 + Then source the completion in your shell profile: 94 + echo 'source $(brew --prefix)/share/bash-completion/bash_completion' >> ~/.bashrc 95 + `; 96 + throw new Error(helpMessage); 82 97 } finally { 83 98 // Clean up 84 99 await unlink(scriptPath).catch(() => {}); ··· 224 239 225 240 // Test for potential bash issues (related to the user's problem) 226 241 describe('bash-specific issue detection', () => { 227 - it('should generate bash script with proper escaping', async () => { 242 + it('should generate bash script with proper syntax (requires bash-completion@2)', async () => { 228 243 const command = `pnpm tsx examples/demo.${cliTool}.ts complete bash`; 229 244 const { stdout } = await exec(command); 230 245 231 - // Check for the actual problematic bash syntax in the requestComp assignment 232 - expect(stdout).not.toMatch(/requestComp="[^"]*\$\{words\[@\]:1\}/); // Should not use ${words[@]:1} in requestComp 246 + // Check that it uses the correct ${words[@]:1} syntax 247 + expect(stdout).toContain('${words[@]:1}'); // Should use ${words[@]:1} (requires bash-completion@2) 233 248 expect(stdout).toContain('requestComp='); // Should have proper variable assignment 234 249 expect(stdout).toContain('complete -F'); // Should register completion properly 250 + expect(stdout).toContain('_get_comp_words_by_ref'); // Should use bash-completion functions 235 251 }); 236 252 237 253 it('should generate bash script that handles empty parameters correctly', async () => {