1pub fn dh_invoke_add_with(line: &str, with_argument: &str) -> String {
5 if line.contains(with_argument) {
6 return line.to_owned();
7 }
8 if !line.contains(" --with") {
9 return format!("{} --with={}", line, with_argument);
10 }
11
12 lazy_regex::regex_replace!(
13 r"([ \t])--with([ =])([^ \t]+)",
14 line,
15 |_, head, with, tail| format!("{}--with={},{}{}", head, with_argument, with, tail)
16 )
17 .to_string()
18}
19
20pub fn dh_invoke_get_with(line: &str) -> Vec<String> {
22 let mut ret = Vec::new();
23 for m in lazy_regex::regex!("[ \t]--with[ =]([^ \t]+)").find_iter(line) {
24 ret.extend(m.as_str().split(',').map(|s| s.to_owned()));
25 }
26 ret
27}