Show real mapping grammar in --help, make --via repeatable, trim comments
- -l/-r/-d now show their actual grammar as the clap value name (<[BIND:]PORT:HOST:PORT>, <[BIND:]PORT>) instead of a generic <SPEC>, matching vmic's convention of showing real syntax in --help. The grammar is no longer also repeated in the flag's help text, since the value name already carries it. - --via changes from a single comma-separated flag to a repeatable one (Vec<String> + value_delimiter = ','), so both `--via a --via b` and `--via a,b` work and can be mixed. commands/mod.rs's edits_from_mapping no longer needs to split the string itself - clap does it. - Trimmed CLI help text that restated grammar/rationale already covered by the value name or by --via being required. - Normalized code comments for tone/format consistency: dropped cross-references to vmic's own internals as justification (this codebase should read as self-contained), removed markdown-style *emphasis* asterisks that don't render in plain comments, tightened several run-on sentences into plain declarative ones, and fixed one comment in wipe.rs that inaccurately described close_instance's force path (it sends SIGKILL, not SIGTERM). - spec/porthole-spec.md's --via row updated to document the repeatable form alongside comma-separated. Cargo.toml/Cargo.lock/atomic.rs also carry an external toml crate bump and formatting pass picked up from the working tree.
This commit is contained in:
@@ -11,12 +11,13 @@ pub mod wipe;
|
||||
use crate::cli::MappingArgs;
|
||||
use crate::profile::ProfileEdits;
|
||||
|
||||
/// Turns clap's `MappingArgs` into a `ProfileEdits`, splitting `--via`'s
|
||||
/// comma-separated raw string into the ordered hop list (spec §5.1).
|
||||
/// 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.as_deref().map(|raw| {
|
||||
raw.split(',').map(str::trim).filter(|s| !s.is_empty()).map(str::to_string).collect::<Vec<_>>()
|
||||
});
|
||||
let via = (!m.via.is_empty()).then(|| m.via.clone());
|
||||
ProfileEdits {
|
||||
local: m.local.clone(),
|
||||
remote: m.remote.clone(),
|
||||
@@ -33,12 +34,12 @@ pub fn edits_from_mapping(m: &MappingArgs) -> ProfileEdits {
|
||||
}
|
||||
|
||||
/// `true` if `MappingArgs` carries no edits at all - used by `edit` to
|
||||
/// reject a no-op invocation the same way vmic's commands do.
|
||||
/// 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_none()
|
||||
&& m.via.is_empty()
|
||||
&& m.user.is_none()
|
||||
&& m.identity.is_none()
|
||||
&& m.port.is_none()
|
||||
|
||||
Reference in New Issue
Block a user