use crate::cli::EditArgs; use crate::commands::{edits_from_mapping, mapping_is_empty}; use crate::error::{PortholeError, Result}; use crate::{instance, profile, ui}; pub fn run(args: EditArgs) -> Result<()> { if mapping_is_empty(&args.mapping) { return Err(PortholeError::NothingToDo( "pass at least one of -l/-r/-d, --via, --user, --identity, --port, --reconnect, \ --retry-interval, --backoff-max, --keepalive." .into(), )); } let name = profile::normalize(&args.name); let mut p = profile::load(&name)?; let edits = edits_from_mapping(&args.mapping); p.apply_edits(&edits)?; profile::save(&p)?; // Spec ยง5.4: edit never restarts a running instance - just warn. if instance::running_pid(&name)?.is_some() { ui::warn(&format!( "'{name}' is currently open; this change won't take effect until the next open/close cycle." )); } ui::ok(&format!("Updated profile '{name}'.")); Ok(()) }