pub mod add; pub mod close; pub mod completions; pub mod edit; pub mod list; pub mod open; pub mod remove; pub mod status; pub mod wipe; use crate::cli::MappingArgs; use crate::profile::ProfileEdits; /// Turns clap's `MappingArgs` into a `ProfileEdits` (spec ยง5.1). `--via` is /// collected by clap itself: `value_delimiter = ','` splits each /// occurrence on commas, and the field being a `Vec` allows repeated /// `--via` flags, so both `--via a,b` and `--via a --via b` reach here as /// `["a", "b"]`. pub fn edits_from_mapping(m: &MappingArgs) -> ProfileEdits { let via = (!m.via.is_empty()).then(|| m.via.clone()); ProfileEdits { local: m.local.clone(), remote: m.remote.clone(), dynamic: m.dynamic.clone(), via, user: m.user.clone(), identity: m.identity.clone(), port: m.port, reconnect: m.reconnect, retry_interval: m.retry_interval, backoff_max: m.backoff_max, keepalive: m.keepalive, } } /// `true` if `MappingArgs` carries no edits at all - used by `edit` to /// reject a no-op invocation. pub fn mapping_is_empty(m: &MappingArgs) -> bool { m.local.is_none() && m.remote.is_none() && m.dynamic.is_none() && m.via.is_empty() && m.user.is_none() && m.identity.is_none() && m.port.is_none() && m.reconnect.is_none() && m.retry_interval.is_none() && m.backoff_max.is_none() && m.keepalive.is_none() }