Also include required arguments in conflict output

This commit is contained in:
tomjw64 2020-08-15 04:17:28 -05:00
parent 4372aa0fa6
commit 6602feb9e6

View file

@ -185,10 +185,20 @@ impl<'help, 'app, 'parser> Validator<'help, 'app, 'parser> {
};
let used: Vec<Id> = matcher
.arg_names()
.filter(|key| *key != latter)
.cloned()
.filter(|key| key != latter)
.collect();
let usg = Usage::new(self.p).create_usage_with_title(&used);
let required: Vec<Id> = used
.iter()
.filter_map(|key| self.p.app.find(key))
.flat_map(|key_arg| key_arg.requires.iter().map(|item| &item.1))
.filter(|item| !used.contains(item))
.filter(|key| *key != latter)
.chain(used.iter())
.cloned()
.collect();
println!("{:?}", required);
let usg = Usage::new(self.p).create_usage_with_title(&required);
return Err(Error::argument_conflict(
former_arg,
Some(latter_arg.to_string()),