Apply suggestions

This commit is contained in:
ldm0 2021-03-09 13:52:12 +00:00
parent 6df56ad289
commit 0b1d137ee9
2 changed files with 8 additions and 4 deletions

View file

@ -43,26 +43,30 @@ pub(crate) fn assert_arg(arg: &Arg) {
);
}
assert_app_flag(arg);
assert_app_flags(arg);
}
fn assert_app_flag(arg: &Arg) {
fn assert_app_flags(arg: &Arg) {
use ArgSettings::*;
macro_rules! checker {
($a:ident requires $($b:ident)|+) => {
if arg.is_set($a) {
let mut s = String::new();
$(
if !arg.is_set($b) {
s.push_str(&format!("\nArgSettings::{} is required when ArgSettings::{} is on.\n", std::stringify!($b), std::stringify!($a)));
s.push_str(&format!("\nArgSettings::{} is required when ArgSettings::{} is set.\n", std::stringify!($b), std::stringify!($a)));
}
)+
if !s.is_empty() {
panic!("{}", s)
}
}
}
}
checker!(AllowEmptyValues requires TakesValue);
checker!(RequireDelimiter requires TakesValue | UseValueDelimiter);
checker!(HidePossibleValues requires TakesValue);

View file

@ -4296,7 +4296,7 @@ impl<'help> Arg<'help> {
/// [`AppSettings::TrailingVarArg`]: ./enum.AppSettings.html#variant.TrailingVarArg
#[inline]
pub fn raw(self, raw: bool) -> Self {
self.takes_value(true)
self.takes_value(raw)
.multiple(raw)
.allow_hyphen_values(raw)
.last(raw)