Fix: Forward flags as well
This is a bugfix. The old implementation did not forward simple commandline flags (as in `--debug`, arguments with no value) because it only used `ArgMatches::value_of()`. But if there is no value, the method returns `None` and the flag is not forwarded. This patch fixes that issue. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
parent
84f2f2c46f
commit
25ee6f2ce4
1 changed files with 14 additions and 7 deletions
|
@ -366,13 +366,20 @@ fn fetch_aliases(config: Option<&Value>) -> Result<BTreeMap<String, String>, Str
|
|||
|
||||
fn forward_commandline_arguments(m: &ArgMatches, scmd: &mut Vec<String>) {
|
||||
let push = |flag: Option<&str>, val_name: &str, m: &ArgMatches, v: &mut Vec<String>| {
|
||||
let _ = m
|
||||
.value_of(val_name)
|
||||
.map(|val| {
|
||||
let flag = format!("--{}", flag.unwrap_or(val_name));
|
||||
v.insert(0, String::from(val));
|
||||
v.insert(0, flag);
|
||||
});
|
||||
if m.is_present(val_name) {
|
||||
let _ = m
|
||||
.value_of(val_name)
|
||||
.map(|val| {
|
||||
debug!("Found '{:?}' = {:?}", val_name, val);
|
||||
let flag = format!("--{}", flag.unwrap_or(val_name));
|
||||
v.insert(0, String::from(val));
|
||||
v.insert(0, flag);
|
||||
})
|
||||
.unwrap_or_else(|| {
|
||||
let flag = format!("--{}", flag.unwrap_or(val_name));
|
||||
v.insert(0, flag);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
push(Some("verbose"),
|
||||
|
|
Loading…
Reference in a new issue