MCPcopy Create free account
hub / github.com/BuddySirJava/SSH-Studio / _on_copy_ssh_command

Method _on_copy_ssh_command

src/ui/host_editor.py:1300–1322  ·  view source on GitHub ↗

Copy the generated SSH command to the clipboard and show a toast.

(self, button)

Source from the content-addressed store, hash-verified

1298 self._show_message(_("Custom option removed"))
1299
1300 def _on_copy_ssh_command(self, button):
1301 """Copy the generated SSH command to the clipboard and show a toast."""
1302 if not self.current_host:
1303 self._show_message(_("No host selected"))
1304 return
1305
1306 try:
1307 hostname = self.hostname_entry.get_text().strip()
1308 if not hostname and self.current_host.patterns:
1309 hostname = self.current_host.patterns[0]
1310 if not hostname:
1311 self._show_message(_("No hostname or pattern available"))
1312 return
1313
1314 command = f"ssh {hostname}"
1315
1316 if not self._copy_text_to_clipboard(command):
1317 raise RuntimeError("clipboard backends unavailable")
1318
1319 self._show_message(_(f"SSH command copied: {command}"))
1320
1321 except Exception as e:
1322 self._show_message(_(f"Failed to copy command: {str(e)}"))
1323
1324 def _copy_text_to_clipboard(self, text: str) -> bool:
1325 try:

Callers

nothing calls this directly

Calls 2

_show_messageMethod · 0.95

Tested by

no test coverage detected