MCPcopy Index your code
hub / github.com/microsoft/vscode-cpptools / addSshTargetImpl

Function addSshTargetImpl

Extension/src/Debugger/extension.ts:170–214  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

168}
169
170async function addSshTargetImpl(): Promise<string> {
171 const validConfigFiles: string[] = [];
172 for (const configFile of getSshConfigurationFiles()) {
173 if (await pathAccessible(configFile) && parseFailures.get(configFile)) {
174 getSshChannel().appendLine(localize('cannot.modify.config.file', 'Cannot modify SSH configuration file because of parse failure "{0}".', configFile));
175 } else {
176 validConfigFiles.push(configFile);
177 }
178 }
179 if (validConfigFiles.length === 0) {
180 throw new Error(localize('no.valid.ssh.config.file', 'No valid SSH configuration file found.'));
181 }
182
183 const name: string | undefined = await vscode.window.showInputBox({
184 title: localize('enter.ssh.target.name', 'Enter SSH Target Name'),
185 placeHolder: localize('ssh.target.name.place.holder', 'Example: `mySSHTarget`'),
186 ignoreFocusOut: true
187 });
188 if (name === undefined) {
189 // Cancelled
190 return '';
191 }
192
193 const command: string | undefined = await vscode.window.showInputBox({
194 title: localize('enter.ssh.connection.command', 'Enter SSH Connection Command'),
195 placeHolder: localize('ssh.connection.command.place.holder', 'Example: `ssh hello@microsoft.com -A`'),
196 ignoreFocusOut: true
197 });
198 if (!command) {
199 return '';
200 }
201
202 const newEntry: { [key: string]: string } = sshCommandToConfig(command, name);
203
204 const targetFile: string | undefined = await vscode.window.showQuickPick(validConfigFiles, { title: localize('select.ssh.config.file', 'Select an SSH configuration file') });
205 if (!targetFile) {
206 return '';
207 }
208
209 const parsedSshConfig: Configuration = await getSshConfiguration(targetFile, false);
210 parsedSshConfig.prepend(newEntry, true);
211 await writeSshConfiguration(targetFile, parsedSshConfig);
212
213 return name;
214}
215
216async function removeSshTargetImpl(node: TargetLeafNode): Promise<boolean> {
217 const labelYes: string = localize('yes', 'Yes');

Callers

nothing calls this directly

Calls 10

getSshConfigurationFilesFunction · 0.90
pathAccessibleFunction · 0.90
getSshChannelFunction · 0.90
sshCommandToConfigFunction · 0.90
getSshConfigurationFunction · 0.90
writeSshConfigurationFunction · 0.90
appendLineMethod · 0.80
pushMethod · 0.80
prependMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected