()
| 168 | } |
| 169 | |
| 170 | async 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 | |
| 216 | async function removeSshTargetImpl(node: TargetLeafNode): Promise<boolean> { |
| 217 | const labelYes: string = localize('yes', 'Yes'); |
nothing calls this directly
no test coverage detected