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>) {
|
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 push = |flag: Option<&str>, val_name: &str, m: &ArgMatches, v: &mut Vec<String>| {
|
||||||
let _ = m
|
if m.is_present(val_name) {
|
||||||
.value_of(val_name)
|
let _ = m
|
||||||
.map(|val| {
|
.value_of(val_name)
|
||||||
let flag = format!("--{}", flag.unwrap_or(val_name));
|
.map(|val| {
|
||||||
v.insert(0, String::from(val));
|
debug!("Found '{:?}' = {:?}", val_name, val);
|
||||||
v.insert(0, flag);
|
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"),
|
push(Some("verbose"),
|
||||||
|
|
Loading…
Reference in a new issue