MCPcopy
hub / github.com/Fission-AI/OpenSpec / installForShell

Method installForShell

src/commands/completion.ts:124–205  ·  view source on GitHub ↗

* Install completion script for a specific shell

(shell: SupportedShell, verbose: boolean)

Source from the content-addressed store, hash-verified

122 * Install completion script for a specific shell
123 */
124 private async installForShell(shell: SupportedShell, verbose: boolean): Promise<void> {
125 const generator = CompletionFactory.createGenerator(shell);
126 const installer = CompletionFactory.createInstaller(shell);
127
128 const spinner = ora(`Installing ${shell} completion script...`).start();
129
130 try {
131 // Generate the completion script
132 const script = generator.generate(COMMAND_REGISTRY);
133
134 // Install it
135 const result = await installer.install(script);
136
137 spinner.stop();
138
139 if (result.success) {
140 console.log(`✓ ${result.message}`);
141
142 if (verbose && result.installedPath) {
143 console.log(` Installed to: ${result.installedPath}`);
144 if (result.backupPath) {
145 console.log(` Backup created: ${result.backupPath}`);
146 }
147
148 // Check if any shell config was updated
149 const configWasUpdated = result.zshrcConfigured || result.bashrcConfigured || result.profileConfigured;
150
151 if (configWasUpdated) {
152 const configPaths: Record<string, string> = {
153 zsh: '~/.zshrc',
154 bash: '~/.bashrc',
155 fish: '~/.config/fish/config.fish',
156 powershell: '$PROFILE',
157 };
158 const configPath = configPaths[shell] || 'config file';
159 console.log(` ${configPath} configured automatically`);
160 }
161 }
162
163 // Display warnings if present
164 if (result.warnings && result.warnings.length > 0) {
165 console.log('');
166 for (const warning of result.warnings) {
167 console.log(warning);
168 }
169 }
170
171 // Print instructions (only shown if .zshrc wasn't auto-configured)
172 if (result.instructions && result.instructions.length > 0) {
173 console.log('');
174 for (const instruction of result.instructions) {
175 console.log(instruction);
176 }
177 } else {
178 // Check if any shell config was updated (InstallationResult has: zshrcConfigured, bashrcConfigured, profileConfigured)
179 const configWasUpdated = result.zshrcConfigured || result.bashrcConfigured || result.profileConfigured;
180
181 if (configWasUpdated) {

Callers 1

installMethod · 0.95

Calls 4

createGeneratorMethod · 0.80
createInstallerMethod · 0.80
generateMethod · 0.65
installMethod · 0.65

Tested by

no test coverage detected