tag_arg

Shared parser and normalizer for --tag/tags CLI arguments.

CLI tag inputs are split on , by clap’s value_delimiter and each piece is trimmed by trim_tag. Because clap’s value_parser cannot drop values, callers must then run the collected list through normalize_tags to discard blank entries produced by stray or trailing commas (e.g. "a,,b" or "a,b,").

fn normalize_tags

source

pub fn normalize_tags(raw: &[String]) -> Vec<String>

Collect tag labels while dropping empty entries produced by stray or trailing commas.

Parameter Type Description
raw &[String] the labels as clap collected them, already trimmed
returns Vec<String> The non-empty labels, each once, in the order they first appear.

fn trim_tag

source

pub fn trim_tag(s: &str) -> Result<String, String>

Trim whitespace around a single tag value.

Used as a clap value_parser on tag arguments so values survive splitting on , with surrounding whitespace preserved only inside labels.

Parameter Type Description
s &str one tag value after clap split the argument on ,
returns Result<String, String> The trimmed value, which may be empty; it never fails.