(gateway: &str, name: &str)
| 1568 | } |
| 1569 | |
| 1570 | pub fn install_ssh_config(gateway: &str, name: &str) -> Result<PathBuf> { |
| 1571 | let managed_config = openshell_ssh_config_path()?; |
| 1572 | let main_config = user_ssh_config_path()?; |
| 1573 | ensure_openshell_include(&main_config, &managed_config)?; |
| 1574 | |
| 1575 | if let Some(parent) = managed_config.parent() { |
| 1576 | openshell_core::paths::create_dir_restricted(parent)?; |
| 1577 | } |
| 1578 | |
| 1579 | let alias = host_alias(name); |
| 1580 | let block = render_ssh_config(gateway, name); |
| 1581 | let contents = fs::read_to_string(&managed_config).unwrap_or_default(); |
| 1582 | let updated = upsert_host_block(&contents, &alias, &block); |
| 1583 | fs::write(&managed_config, updated) |
| 1584 | .into_diagnostic() |
| 1585 | .wrap_err("failed to write OpenShell SSH config")?; |
| 1586 | Ok(managed_config) |
| 1587 | } |
| 1588 | |
| 1589 | fn launch_editor(editor: Editor, host_alias: &str) -> Result<()> { |
| 1590 | launch_editor_command( |
no test coverage detected