feat: Add Arg getters for all settings

This is prep for #2717
This commit is contained in:
Ed Page 2022-02-09 11:16:34 -06:00
parent 519fcc2e11
commit 47d76742eb
32 changed files with 773 additions and 552 deletions

View file

@ -1,6 +1,6 @@
//! Helpers for writing generators
use clap::{App, Arg, ArgSettings};
use clap::{App, Arg};
/// Gets all subcommands including child subcommands in the form of `("name", "bin_name")`.
///
@ -121,7 +121,7 @@ pub fn longs_and_visible_aliases(p: &App) -> Vec<String> {
pub fn flags<'help>(p: &App<'help>) -> Vec<Arg<'help>> {
debug!("flags: name={}", p.get_name());
p.get_arguments()
.filter(|a| !a.is_set(ArgSettings::TakesValue) && !a.is_positional())
.filter(|a| !a.is_takes_value_set() && !a.is_positional())
.cloned()
.collect()
}

View file

@ -143,7 +143,7 @@ fn gen_fish_inner(root_command: &str, parent_commands: &[&str], app: &App, buffe
}
fn value_completion(option: &Arg) -> String {
if !option.is_set(ArgSettings::TakesValue) {
if !option.is_takes_value_set() {
return "".to_string();
}

View file

@ -359,14 +359,14 @@ fn value_completion(arg: &Arg) -> Option<String> {
if let Some(values) = &arg.get_possible_values() {
if values
.iter()
.any(|value| !value.is_hidden() && value.get_help().is_some())
.any(|value| !value.is_hide_set() && value.get_help().is_some())
{
Some(format!(
"(({}))",
values
.iter()
.filter_map(|value| {
if value.is_hidden() {
if value.is_hide_set() {
None
} else {
Some(format!(
@ -447,7 +447,7 @@ fn write_opts_of(p: &App, p_global: Option<&App>) -> String {
let help = o.get_help().map_or(String::new(), escape_help);
let conflicts = arg_conflicts(p, o, p_global);
let multiple = if o.is_set(ArgSettings::MultipleOccurrences) {
let multiple = if o.is_multiple_occurrences_set() {
"*"
} else {
""
@ -550,7 +550,7 @@ fn write_flags_of(p: &App, p_global: Option<&App>) -> String {
let help = f.get_help().map_or(String::new(), escape_help);
let conflicts = arg_conflicts(p, &f, p_global);
let multiple = if f.is_set(ArgSettings::MultipleOccurrences) {
let multiple = if f.is_multiple_occurrences_set() {
"*"
} else {
""
@ -628,11 +628,9 @@ fn write_positionals_of(p: &App) -> String {
for arg in p.get_positionals() {
debug!("write_positionals_of:iter: arg={}", arg.get_name());
let cardinality = if arg.is_set(ArgSettings::MultipleValues)
|| arg.is_set(ArgSettings::MultipleOccurrences)
{
let cardinality = if arg.is_multiple_values_set() || arg.is_multiple_occurrences_set() {
"*:"
} else if !arg.is_set(ArgSettings::Required) {
} else if !arg.is_required_set() {
":"
} else {
""

View file

@ -212,7 +212,7 @@ fn gen_options(app: &App, indent: usize) -> String {
}
fn gen_args(arg: &Arg, indent: usize) -> String {
if !arg.is_set(ArgSettings::TakesValue) {
if !arg.is_takes_value_set() {
return "".to_string();
}
@ -225,7 +225,7 @@ fn gen_args(arg: &Arg, indent: usize) -> String {
indent = indent
));
if arg.is_set(ArgSettings::MultipleValues) {
if arg.is_multiple_values_set() {
buffer.push_str(&format!(
"{:indent$}isVariadic: true,\n",
"",
@ -233,7 +233,7 @@ fn gen_args(arg: &Arg, indent: usize) -> String {
));
}
if !arg.is_set(ArgSettings::Required) {
if !arg.is_required_set() {
buffer.push_str(&format!(
"{:indent$}isOptional: true,\n",
"",

View file

@ -259,8 +259,7 @@ fn app_has_version(app: &clap::App) -> bool {
// Does the application have any command line arguments?
fn app_has_arguments(app: &clap::App) -> bool {
app.get_arguments()
.any(|i| !i.is_set(clap::ArgSettings::Hidden))
app.get_arguments().any(|i| !i.is_hide_set())
}
// Does the application have any subcommands?

View file

@ -1,4 +1,4 @@
use clap::{AppSettings, ArgSettings};
use clap::AppSettings;
use roff::{bold, italic, roman, Inline, Roff};
pub(crate) fn subcommand_heading(app: &clap::App) -> String {
@ -81,10 +81,7 @@ pub(crate) fn synopsis(roff: &mut Roff, app: &clap::App) {
}
pub(crate) fn options(roff: &mut Roff, app: &clap::App) {
let items: Vec<_> = app
.get_arguments()
.filter(|i| !i.is_set(ArgSettings::Hidden))
.collect();
let items: Vec<_> = app.get_arguments().filter(|i| !i.is_hide_set()).collect();
for opt in items.iter().filter(|a| !a.is_positional()) {
let mut body = vec![];
@ -189,7 +186,7 @@ fn subcommand_markers(cmd: &clap::App) -> (&'static str, &'static str) {
}
fn option_markers(opt: &clap::Arg) -> (&'static str, &'static str) {
markers(opt.is_set(ArgSettings::Required))
markers(opt.is_required_set())
}
fn markers(required: bool) -> (&'static str, &'static str) {
@ -209,7 +206,7 @@ fn long_option(opt: &str) -> Inline {
}
fn option_environment(opt: &clap::Arg) -> Option<Vec<Inline>> {
if opt.is_set(ArgSettings::HideEnv) {
if opt.is_hide_env_set() {
return None;
} else if let Some(env) = opt.get_env() {
return Some(vec![

View file

@ -24,7 +24,7 @@ fn main() {
.exclusive(true)
.takes_value(true)
.default_missing_value("/usr/local/bin")
.use_delimiter(false),
.use_value_delimiter(false),
)
.subcommands(applet_commands()),
)

View file

@ -2,7 +2,7 @@ use crate::{
build::arg::{debug_asserts::assert_arg, ArgProvider},
mkeymap::KeyType,
util::Id,
App, AppSettings, Arg, ArgSettings, ValueHint,
App, AppSettings, Arg, ValueHint,
};
use std::cmp::Ordering;
@ -177,7 +177,7 @@ pub(crate) fn assert_app(app: &App) {
);
}
if arg.is_set(ArgSettings::Last) {
if arg.is_last_set() {
assert!(
arg.long.is_none(),
"App {}: Flags or Options cannot have last(true) set. '{}' has both a long and last(true) set.",
@ -193,7 +193,7 @@ pub(crate) fn assert_app(app: &App) {
}
assert!(
!(arg.is_set(ArgSettings::Required) && arg.get_global()),
!(arg.is_required_set() && arg.is_global_set()),
"App {}: Global arguments cannot be required.\n\n\t'{}' is marked as both global and required",
app.get_name(),
arg.name
@ -463,9 +463,9 @@ fn _verify_positionals(app: &App) -> bool {
// Either the final positional is required
// Or the second to last has a terminator or .last(true) set
let ok = last.is_set(ArgSettings::Required)
|| (second_to_last.terminator.is_some() || second_to_last.is_set(ArgSettings::Last))
|| last.is_set(ArgSettings::Last);
let ok = last.is_required_set()
|| (second_to_last.terminator.is_some() || second_to_last.is_last_set())
|| last.is_last_set();
assert!(
ok,
"When using a positional argument with .multiple_values(true) that is *not the \
@ -474,7 +474,7 @@ fn _verify_positionals(app: &App) -> bool {
);
// We make sure if the second to last is Multiple the last is ArgSettings::Last
let ok = second_to_last.is_multiple() || last.is_set(ArgSettings::Last);
let ok = second_to_last.is_multiple() || last.is_last_set();
assert!(
ok,
"Only the last positional argument, or second to last positional \
@ -485,12 +485,12 @@ fn _verify_positionals(app: &App) -> bool {
let count = app
.get_positionals()
.filter(|p| {
p.settings.is_set(ArgSettings::MultipleOccurrences)
|| (p.settings.is_set(ArgSettings::MultipleValues) && p.num_vals.is_none())
p.is_multiple_occurrences_set()
|| (p.is_multiple_values_set() && p.num_vals.is_none())
})
.count();
let ok = count <= 1
|| (last.is_set(ArgSettings::Last)
|| (last.is_last_set()
&& last.is_multiple()
&& second_to_last.is_multiple()
&& count == 2);
@ -509,16 +509,16 @@ fn _verify_positionals(app: &App) -> bool {
let mut foundx2 = false;
for p in app.get_positionals() {
if foundx2 && !p.is_set(ArgSettings::Required) {
if foundx2 && !p.is_required_set() {
assert!(
p.is_set(ArgSettings::Required),
p.is_required_set(),
"Found non-required positional argument with a lower \
index than a required positional argument by two or more: {:?} \
index {:?}",
p.name,
p.index
);
} else if p.is_set(ArgSettings::Required) && !p.is_set(ArgSettings::Last) {
} else if p.is_required_set() && !p.is_last_set() {
// Args that .last(true) don't count since they can be required and have
// positionals with a lower index that aren't required
// Imagine: prog <req1> [opt1] -- <req2>
@ -541,13 +541,13 @@ fn _verify_positionals(app: &App) -> bool {
for p in (1..=num_p).rev().filter_map(|n| app.args.get(&n)) {
if found {
assert!(
p.is_set(ArgSettings::Required),
p.is_required_set(),
"Found non-required positional argument with a lower \
index than a required positional argument: {:?} index {:?}",
p.name,
p.index
);
} else if p.is_set(ArgSettings::Required) && !p.is_set(ArgSettings::Last) {
} else if p.is_required_set() && !p.is_last_set() {
// Args that .last(true) don't count since they can be required and have
// positionals with a lower index that aren't required
// Imagine: prog <req1> [opt1] -- <req2>
@ -560,15 +560,12 @@ fn _verify_positionals(app: &App) -> bool {
}
}
assert!(
app.get_positionals()
.filter(|p| p.is_set(ArgSettings::Last))
.count()
< 2,
app.get_positionals().filter(|p| p.is_last_set()).count() < 2,
"Only one positional argument may have last(true) set. Found two."
);
if app
.get_positionals()
.any(|p| p.is_set(ArgSettings::Last) && p.is_set(ArgSettings::Required))
.any(|p| p.is_last_set() && p.is_required_set())
&& app.has_subcommands()
&& !app.is_set(AppSettings::SubcommandsNegateReqs)
{

View file

@ -23,7 +23,7 @@ use os_str_bytes::RawOsStr;
use yaml_rust::Yaml;
// Internal
use crate::build::{arg::ArgProvider, Arg, ArgGroup, ArgPredicate, ArgSettings};
use crate::build::{arg::ArgProvider, Arg, ArgGroup, ArgPredicate};
use crate::error::ErrorKind;
use crate::error::Result as ClapResult;
use crate::mkeymap::MKeyMap;
@ -2373,7 +2373,7 @@ impl<'help> App<'help> {
/// Iterate through the *options*.
pub fn get_opts(&self) -> impl Iterator<Item = &Arg<'help>> {
self.get_arguments()
.filter(|a| a.is_set(ArgSettings::TakesValue) && !a.is_positional())
.filter(|a| a.is_takes_value_set() && !a.is_positional())
}
/// Get a list of all arguments the given argument conflicts with.
@ -2387,7 +2387,7 @@ impl<'help> App<'help> {
/// this `App`.
pub fn get_arg_conflicts_with(&self, arg: &Arg) -> Vec<&Arg<'help>> // FIXME: This could probably have been an iterator
{
if arg.get_global() {
if arg.is_global_set() {
self.get_global_arg_conflicts_with(arg)
} else {
arg.blacklist
@ -2708,7 +2708,7 @@ impl<'help> App<'help> {
global_arg_vec.extend(
self.args
.args()
.filter(|a| a.get_global())
.filter(|a| a.is_global_set())
.map(|ga| ga.id.clone()),
);
if let Some((id, matches)) = matches.subcommand() {
@ -2783,7 +2783,7 @@ impl<'help> App<'help> {
}
// Figure out implied settings
if a.is_set(ArgSettings::Last) {
if a.is_last_set() {
// if an arg has `Last` set, we need to imply DontCollapseArgsInUsage so that args
// in the usage string don't get confused or left out.
self.settings.set(AppSettings::DontCollapseArgsInUsage);
@ -2852,7 +2852,7 @@ impl<'help> App<'help> {
debug!("App::_propagate_global_args:{}", self.name);
for sc in &mut self.subcommands {
for a in self.args.args().filter(|a| a.get_global()) {
for a in self.args.args().filter(|a| a.is_global_set()) {
let mut propagate = false;
let is_generated = matches!(
a.provider,

View file

@ -256,7 +256,7 @@ pub enum AppSettings {
/// was used.
///
/// **NOTE:** The same thing can be done manually by setting the final positional argument to
/// [`Arg::use_delimiter(false)`]. Using this setting is safer, because it's easier to locate
/// [`Arg::use_value_delimiter(false)`]. Using this setting is safer, because it's easier to locate
/// when making changes.
///
/// # Examples
@ -268,7 +268,7 @@ pub enum AppSettings {
/// .get_matches();
/// ```
///
/// [`Arg::use_delimiter(false)`]: crate::Arg::use_delimiter()
/// [`Arg::use_value_delimiter(false)`]: crate::Arg::use_value_delimiter()
DontDelimitTrailingValues,
/// Allow partial matches of long arguments or their [aliases].

View file

@ -1,4 +1,4 @@
use crate::{Arg, ArgSettings, ValueHint};
use crate::{Arg, ValueHint};
pub(crate) fn assert_arg(arg: &Arg) {
debug!("Arg::_debug_asserts:{}", arg.name);
@ -13,14 +13,14 @@ pub(crate) fn assert_arg(arg: &Arg) {
if arg.value_hint != ValueHint::Unknown {
assert!(
arg.is_set(ArgSettings::TakesValue),
arg.is_takes_value_set(),
"Argument '{}' has value hint but takes no value",
arg.name
);
if arg.value_hint == ValueHint::CommandWithArguments {
assert!(
arg.is_set(ArgSettings::MultipleValues),
arg.is_multiple_values_set(),
"Argument '{}' uses hint CommandWithArguments and must accept multiple values",
arg.name
)
@ -35,7 +35,7 @@ pub(crate) fn assert_arg(arg: &Arg) {
);
}
if arg.is_set(ArgSettings::Required) {
if arg.is_required_set() {
assert!(
arg.default_vals.is_empty(),
"Argument '{}' is required and can't have a default value",
@ -61,16 +61,14 @@ pub(crate) fn assert_arg(arg: &Arg) {
}
fn assert_arg_flags(arg: &Arg) {
use ArgSettings::*;
macro_rules! checker {
($a:ident requires $($b:ident)|+) => {
if arg.is_set($a) {
if arg.$a() {
let mut s = String::new();
$(
if !arg.is_set($b) {
s.push_str(&format!(" ArgSettings::{} is required when ArgSettings::{} is set.\n", std::stringify!($b), std::stringify!($a)));
if !arg.$b() {
s.push_str(&format!(" Arg::{} is required when Arg::{} is set.\n", std::stringify!($b), std::stringify!($a)));
}
)+
@ -81,16 +79,17 @@ fn assert_arg_flags(arg: &Arg) {
}
}
checker!(ForbidEmptyValues requires TakesValue);
checker!(RequireDelimiter requires TakesValue | UseValueDelimiter);
checker!(HidePossibleValues requires TakesValue);
checker!(AllowHyphenValues requires TakesValue);
checker!(RequireEquals requires TakesValue);
checker!(Last requires TakesValue);
checker!(HideDefaultValue requires TakesValue);
checker!(MultipleValues requires TakesValue);
checker!(IgnoreCase requires TakesValue);
checker!(AllowInvalidUtf8 requires TakesValue);
checker!(is_forbid_empty_values_set requires is_takes_value_set);
checker!(is_require_value_delimiter_set requires is_takes_value_set);
checker!(is_require_value_delimiter_set requires is_use_value_delimiter_set);
checker!(is_hide_possible_values_set requires is_takes_value_set);
checker!(is_allow_hyphen_values_set requires is_takes_value_set);
checker!(is_require_equals_set requires is_takes_value_set);
checker!(is_last_set requires is_takes_value_set);
checker!(is_hide_default_value_set requires is_takes_value_set);
checker!(is_multiple_values_set requires is_takes_value_set);
checker!(is_ignore_case_set requires is_takes_value_set);
checker!(is_allow_invalid_utf8_set requires is_takes_value_set);
}
fn assert_defaults<'d>(
@ -103,7 +102,7 @@ fn assert_defaults<'d>(
if !arg.possible_vals.is_empty() {
assert!(
arg.possible_vals.iter().any(|possible_val| {
possible_val.matches(default_s, arg.is_set(ArgSettings::IgnoreCase))
possible_val.matches(default_s, arg.is_ignore_case_set())
}),
"Argument `{}`'s {}={} doesn't match possible values",
arg.name,

View file

@ -887,6 +887,7 @@ impl<'help> Arg<'help> {
///
/// [`ArgSettings`]: crate::ArgSettings
#[inline]
// TODO: Deprecate
pub fn is_set(&self, s: ArgSettings) -> bool {
self.settings.is_set(s)
}
@ -913,6 +914,7 @@ impl<'help> Arg<'help> {
/// ```
#[inline]
#[must_use]
// TODO: Deprecate
pub fn setting<F>(mut self, setting: F) -> Self
where
F: Into<ArgFlags>,
@ -943,6 +945,7 @@ impl<'help> Arg<'help> {
/// ```
#[inline]
#[must_use]
// TODO: Deprecate
pub fn unset_setting<F>(mut self, setting: F) -> Self
where
F: Into<ArgFlags>,
@ -966,7 +969,7 @@ impl<'help> Arg<'help> {
/// `--option=val1,val2,val3` is three values for the `--option` argument. If you wish to
/// change the delimiter to another character you can use [`Arg::value_delimiter(char)`],
/// alternatively you can turn delimiting values **OFF** by using
/// [`Arg::use_delimiter(false)`][Arg::use_delimiter]
/// [`Arg::use_value_delimiter(false)`][Arg::use_value_delimiter]
///
/// # Examples
///
@ -2077,6 +2080,70 @@ impl<'help> Arg<'help> {
}
}
/// Specifies that an argument should allow grouping of multiple values via a
/// delimiter.
///
/// i.e. should `--option=val1,val2,val3` be parsed as three values (`val1`, `val2`,
/// and `val3`) or as a single value (`val1,val2,val3`). Defaults to using `,` (comma) as the
/// value delimiter for all arguments that accept values (options and positional arguments)
///
/// **NOTE:** When this setting is used, it will default [`Arg::value_delimiter`]
/// to the comma `,`.
///
/// **NOTE:** Implicitly sets [`Arg::takes_value`]
///
/// # Examples
///
/// The following example shows the default behavior.
///
/// ```rust
/// # use clap::{App, Arg};
/// let delims = App::new("prog")
/// .arg(Arg::new("option")
/// .long("option")
/// .use_value_delimiter(true)
/// .takes_value(true))
/// .get_matches_from(vec![
/// "prog", "--option=val1,val2,val3",
/// ]);
///
/// assert!(delims.is_present("option"));
/// assert_eq!(delims.occurrences_of("option"), 1);
/// assert_eq!(delims.values_of("option").unwrap().collect::<Vec<_>>(), ["val1", "val2", "val3"]);
/// ```
/// The next example shows the difference when turning delimiters off. This is the default
/// behavior
///
/// ```rust
/// # use clap::{App, Arg};
/// let nodelims = App::new("prog")
/// .arg(Arg::new("option")
/// .long("option")
/// .takes_value(true))
/// .get_matches_from(vec![
/// "prog", "--option=val1,val2,val3",
/// ]);
///
/// assert!(nodelims.is_present("option"));
/// assert_eq!(nodelims.occurrences_of("option"), 1);
/// assert_eq!(nodelims.value_of("option").unwrap(), "val1,val2,val3");
/// ```
/// [`Arg::value_delimiter`]: Arg::value_delimiter()
#[inline]
#[must_use]
pub fn use_value_delimiter(mut self, yes: bool) -> Self {
if yes {
if self.val_delim.is_none() {
self.val_delim = Some(',');
}
self.takes_value(true)
.setting(ArgSettings::UseValueDelimiter)
} else {
self.val_delim = None;
self.unset_setting(ArgSettings::UseValueDelimiter)
}
}
/// Specifies that an argument should allow grouping of multiple values via a
/// delimiter.
///
@ -2128,22 +2195,14 @@ impl<'help> Arg<'help> {
/// [`Arg::value_delimiter`]: Arg::value_delimiter()
#[inline]
#[must_use]
pub fn use_delimiter(mut self, yes: bool) -> Self {
if yes {
if self.val_delim.is_none() {
self.val_delim = Some(',');
}
self.takes_value(true)
.setting(ArgSettings::UseValueDelimiter)
} else {
self.val_delim = None;
self.unset_setting(ArgSettings::UseValueDelimiter)
}
// TODO: Deprecate
pub fn use_delimiter(self, yes: bool) -> Self {
self.use_value_delimiter(yes)
}
/// Separator between the arguments values, defaults to `,` (comma).
///
/// **NOTE:** implicitly sets [`Arg::use_delimiter(true)`]
/// **NOTE:** implicitly sets [`Arg::use_value_delimiter(true)`]
///
/// **NOTE:** implicitly sets [`Arg::takes_value(true)`]
///
@ -2162,13 +2221,13 @@ impl<'help> Arg<'help> {
///
/// assert_eq!(m.values_of("config").unwrap().collect::<Vec<_>>(), ["val1", "val2", "val3"])
/// ```
/// [`Arg::use_delimiter(true)`]: Arg::use_delimiter()
/// [`Arg::use_value_delimiter(true)`]: Arg::use_value_delimiter()
/// [`Arg::takes_value(true)`]: Arg::takes_value()
#[inline]
#[must_use]
pub fn value_delimiter(mut self, d: char) -> Self {
self.val_delim = Some(d);
self.takes_value(true).use_delimiter(true)
self.takes_value(true).use_value_delimiter(true)
}
/// Specifies that *multiple values* may only be set using the delimiter.
@ -2179,7 +2238,7 @@ impl<'help> Arg<'help> {
///
/// **NOTE:** The default is `false`.
///
/// **NOTE:** Setting this requires [`Arg::use_delimiter`] and
/// **NOTE:** Setting this requires [`Arg::use_value_delimiter`] and
/// [`Arg::takes_value`]
///
/// **NOTE:** It's a good idea to inform the user that use of a delimiter is required, either
@ -2196,7 +2255,7 @@ impl<'help> Arg<'help> {
/// .arg(Arg::new("opt")
/// .short('o')
/// .takes_value(true)
/// .use_delimiter(true)
/// .use_value_delimiter(true)
/// .require_delimiter(true)
/// .multiple_values(true))
/// .get_matches_from(vec![
@ -2215,7 +2274,7 @@ impl<'help> Arg<'help> {
/// .arg(Arg::new("opt")
/// .short('o')
/// .takes_value(true)
/// .use_delimiter(true)
/// .use_value_delimiter(true)
/// .require_delimiter(true))
/// .try_get_matches_from(vec![
/// "prog", "-o", "val1", "val2", "val3",
@ -2249,7 +2308,7 @@ impl<'help> Arg<'help> {
/// ```
#[inline]
#[must_use]
pub fn require_delimiter(self, yes: bool) -> Self {
pub fn require_value_delimiter(self, yes: bool) -> Self {
if yes {
self.setting(ArgSettings::RequireDelimiter)
} else {
@ -2257,6 +2316,89 @@ impl<'help> Arg<'help> {
}
}
/// Specifies that *multiple values* may only be set using the delimiter.
///
/// This means if an option is encountered, and no delimiter is found, it is assumed that no
/// additional values for that option follow. This is unlike the default, where it is generally
/// assumed that more values will follow regardless of whether or not a delimiter is used.
///
/// **NOTE:** The default is `false`.
///
/// **NOTE:** Setting this requires [`Arg::use_value_delimiter`] and
/// [`Arg::takes_value`]
///
/// **NOTE:** It's a good idea to inform the user that use of a delimiter is required, either
/// through help text or other means.
///
/// # Examples
///
/// These examples demonstrate what happens when `require_delimiter(true)` is used. Notice
/// everything works in this first example, as we use a delimiter, as expected.
///
/// ```rust
/// # use clap::{App, Arg};
/// let delims = App::new("prog")
/// .arg(Arg::new("opt")
/// .short('o')
/// .takes_value(true)
/// .use_value_delimiter(true)
/// .require_delimiter(true)
/// .multiple_values(true))
/// .get_matches_from(vec![
/// "prog", "-o", "val1,val2,val3",
/// ]);
///
/// assert!(delims.is_present("opt"));
/// assert_eq!(delims.values_of("opt").unwrap().collect::<Vec<_>>(), ["val1", "val2", "val3"]);
/// ```
///
/// In this next example, we will *not* use a delimiter. Notice it's now an error.
///
/// ```rust
/// # use clap::{App, Arg, ErrorKind};
/// let res = App::new("prog")
/// .arg(Arg::new("opt")
/// .short('o')
/// .takes_value(true)
/// .use_value_delimiter(true)
/// .require_delimiter(true))
/// .try_get_matches_from(vec![
/// "prog", "-o", "val1", "val2", "val3",
/// ]);
///
/// assert!(res.is_err());
/// let err = res.unwrap_err();
/// assert_eq!(err.kind(), ErrorKind::UnknownArgument);
/// ```
///
/// What's happening is `-o` is getting `val1`, and because delimiters are required yet none
/// were present, it stops parsing `-o`. At this point it reaches `val2` and because no
/// positional arguments have been defined, it's an error of an unexpected argument.
///
/// In this final example, we contrast the above with `clap`'s default behavior where the above
/// is *not* an error.
///
/// ```rust
/// # use clap::{App, Arg};
/// let delims = App::new("prog")
/// .arg(Arg::new("opt")
/// .short('o')
/// .takes_value(true)
/// .multiple_values(true))
/// .get_matches_from(vec![
/// "prog", "-o", "val1", "val2", "val3",
/// ]);
///
/// assert!(delims.is_present("opt"));
/// assert_eq!(delims.values_of("opt").unwrap().collect::<Vec<_>>(), ["val1", "val2", "val3"]);
/// ```
#[inline]
#[must_use]
// TODO: Deprecate
pub fn require_delimiter(self, yes: bool) -> Self {
self.require_value_delimiter(yes)
}
/// Sentinel to **stop** parsing multiple values of a give argument.
///
/// By default when
@ -2690,7 +2832,7 @@ impl<'help> Arg<'help> {
/// .env("MY_FLAG_MULTI")
/// .takes_value(true)
/// .multiple_values(true)
/// .use_delimiter(true))
/// .use_value_delimiter(true))
/// .get_matches_from(vec![
/// "prog"
/// ]);
@ -2701,7 +2843,7 @@ impl<'help> Arg<'help> {
/// [`ArgMatches::value_of`]: crate::ArgMatches::value_of()
/// [`ArgMatches::is_present`]: ArgMatches::is_present()
/// [`Arg::takes_value(true)`]: Arg::takes_value()
/// [`Arg::use_delimiter(true)`]: Arg::use_delimiter()
/// [`Arg::use_value_delimiter(true)`]: Arg::use_value_delimiter()
#[cfg(feature = "env")]
#[inline]
#[must_use]
@ -4626,8 +4768,9 @@ impl<'help> Arg<'help> {
}
/// Get information on if this argument is global or not
// TODO: Deprecate
pub fn get_global(&self) -> bool {
self.is_set(ArgSettings::Global)
self.is_global_set()
}
/// Get the environment variable name specified for this argument, if any
@ -4673,6 +4816,118 @@ impl<'help> Arg<'help> {
pub fn is_positional(&self) -> bool {
self.long.is_none() && self.short.is_none()
}
/// Reports whether [`Arg::required`] is set
pub fn is_required_set(&self) -> bool {
self.is_set(ArgSettings::Required)
}
/// Report whether [`Arg::multiple_values`] is set
pub fn is_multiple_values_set(&self) -> bool {
self.is_set(ArgSettings::MultipleValues)
}
/// Report whether [`Arg::multiple_occurrences`] is set
pub fn is_multiple_occurrences_set(&self) -> bool {
self.is_set(ArgSettings::MultipleOccurrences)
}
/// Report whether [`Arg::is_takes_value_set`] is set
pub fn is_takes_value_set(&self) -> bool {
self.is_set(ArgSettings::TakesValue)
}
/// Report whether [`Arg::allow_hyphen_values`] is set
pub fn is_allow_hyphen_values_set(&self) -> bool {
self.is_set(ArgSettings::AllowHyphenValues)
}
/// Report whether [`Arg::forbid_empty_values`] is set
pub fn is_forbid_empty_values_set(&self) -> bool {
self.is_set(ArgSettings::ForbidEmptyValues)
}
/// Report whether [`Arg::is_allow_invalid_utf8_set`] is set
pub fn is_allow_invalid_utf8_set(&self) -> bool {
self.is_set(ArgSettings::AllowInvalidUtf8)
}
/// Report whether [`Arg::global`] is set
pub fn is_global_set(&self) -> bool {
self.is_set(ArgSettings::Global)
}
/// Report whether [`Arg::next_line_help`] is set
pub fn is_next_line_help_set(&self) -> bool {
self.is_set(ArgSettings::NextLineHelp)
}
/// Report whether [`Arg::hide`] is set
pub fn is_hide_set(&self) -> bool {
self.is_set(ArgSettings::Hidden)
}
/// Report whether [`Arg::hide_default_value`] is set
pub fn is_hide_default_value_set(&self) -> bool {
self.is_set(ArgSettings::HideDefaultValue)
}
/// Report whether [`Arg::hide_possible_values`] is set
pub fn is_hide_possible_values_set(&self) -> bool {
self.is_set(ArgSettings::HidePossibleValues)
}
/// Report whether [`Arg::hide_env`] is set
#[cfg(feature = "env")]
pub fn is_hide_env_set(&self) -> bool {
self.is_set(ArgSettings::HideEnv)
}
/// Report whether [`Arg::hide_env_values`] is set
#[cfg(feature = "env")]
pub fn is_hide_env_values_set(&self) -> bool {
self.is_set(ArgSettings::HideEnvValues)
}
/// Report whether [`Arg::hide_short_help`] is set
pub fn is_hide_short_help_set(&self) -> bool {
self.is_set(ArgSettings::HiddenShortHelp)
}
/// Report whether [`Arg::hide_long_help`] is set
pub fn is_hide_long_help_set(&self) -> bool {
self.is_set(ArgSettings::HiddenLongHelp)
}
/// Report whether [`Arg::use_value_delimiter`] is set
pub fn is_use_value_delimiter_set(&self) -> bool {
self.is_set(ArgSettings::UseValueDelimiter)
}
/// Report whether [`Arg::require_value_delimiter`] is set
pub fn is_require_value_delimiter_set(&self) -> bool {
self.is_set(ArgSettings::RequireDelimiter)
}
/// Report whether [`Arg::require_equals`] is set
pub fn is_require_equals_set(&self) -> bool {
self.is_set(ArgSettings::RequireEquals)
}
/// Reports whether [`Arg::exclusive`] is set
pub fn is_exclusive_set(&self) -> bool {
self.is_set(ArgSettings::Exclusive)
}
/// Reports whether [`Arg::last`] is set
pub fn is_last_set(&self) -> bool {
self.is_set(ArgSettings::Last)
}
/// Reports whether [`Arg::ignore_case`] is set
pub fn is_ignore_case_set(&self) -> bool {
self.is_set(ArgSettings::IgnoreCase)
}
}
/// Deprecated
@ -4883,8 +5138,7 @@ impl<'help> Arg<'help> {
self.settings.set(ArgSettings::TakesValue);
}
if (self.is_set(ArgSettings::UseValueDelimiter)
|| self.is_set(ArgSettings::RequireDelimiter))
if (self.is_use_value_delimiter_set() || self.is_require_value_delimiter_set())
&& self.val_delim.is_none()
{
self.val_delim = Some(',');
@ -4901,7 +5155,7 @@ impl<'help> Arg<'help> {
}
let self_id = self.id.clone();
if self.is_positional() || self.is_set(ArgSettings::MultipleOccurrences) {
if self.is_positional() || self.is_multiple_occurrences_set() {
// Remove self-overrides where they don't make sense.
//
// We can evaluate switching this to a debug assert at a later time (though it will
@ -4917,16 +5171,13 @@ impl<'help> Arg<'help> {
}
pub(crate) fn longest_filter(&self) -> bool {
self.is_set(ArgSettings::TakesValue) || self.long.is_some() || self.short.is_none()
self.is_takes_value_set() || self.long.is_some() || self.short.is_none()
}
// Used for positionals when printing
pub(crate) fn multiple_str(&self) -> &str {
let mult_vals = self.val_names.len() > 1;
if (self.is_set(ArgSettings::MultipleValues)
|| self.is_set(ArgSettings::MultipleOccurrences))
&& !mult_vals
{
if (self.is_multiple_values_set() || self.is_multiple_occurrences_set()) && !mult_vals {
"..."
} else {
""
@ -4936,7 +5187,7 @@ impl<'help> Arg<'help> {
// Used for positionals when printing
pub(crate) fn name_no_brackets(&self) -> Cow<str> {
debug!("Arg::name_no_brackets:{}", self.name);
let delim = if self.is_set(ArgSettings::RequireDelimiter) {
let delim = if self.is_require_value_delimiter_set() {
self.val_delim.expect(INTERNAL_ERROR_MSG)
} else {
' '
@ -4964,7 +5215,7 @@ impl<'help> Arg<'help> {
/// Either multiple values or occurrences
pub(crate) fn is_multiple(&self) -> bool {
self.is_set(ArgSettings::MultipleValues) | self.is_set(ArgSettings::MultipleOccurrences)
self.is_multiple_values_set() | self.is_multiple_occurrences_set()
}
pub(crate) fn get_display_order(&self) -> usize {
@ -5007,9 +5258,9 @@ impl<'help> Display for Arg<'help> {
write!(f, "-{}", s)?;
}
let mut need_closing_bracket = false;
if !self.is_positional() && self.is_set(ArgSettings::TakesValue) {
if !self.is_positional() && self.is_takes_value_set() {
let is_optional_val = self.min_vals == Some(0);
let sep = if self.is_set(ArgSettings::RequireEquals) {
let sep = if self.is_require_equals_set() {
if is_optional_val {
need_closing_bracket = true;
"[="
@ -5024,7 +5275,7 @@ impl<'help> Display for Arg<'help> {
};
f.write_str(sep)?;
}
if self.is_set(ArgSettings::TakesValue) || self.is_positional() {
if self.is_takes_value_set() || self.is_positional() {
display_arg_val(self, |s, _| f.write_str(s))?;
}
if need_closing_bracket {
@ -5110,9 +5361,9 @@ pub(crate) fn display_arg_val<F, T, E>(arg: &Arg, mut write: F) -> Result<(), E>
where
F: FnMut(&str, bool) -> Result<T, E>,
{
let mult_val = arg.is_set(ArgSettings::MultipleValues);
let mult_occ = arg.is_set(ArgSettings::MultipleOccurrences);
let delim = if arg.is_set(ArgSettings::RequireDelimiter) {
let mult_val = arg.is_multiple_values_set();
let mult_occ = arg.is_multiple_occurrences_set();
let delim = if arg.is_require_value_delimiter_set() {
arg.val_delim.expect(INTERNAL_ERROR_MSG)
} else {
' '

View file

@ -150,7 +150,14 @@ impl<'help> PossibleValue<'help> {
/// Should the value be hidden from help messages and completion
#[inline]
// TODO: Deprecate
pub fn is_hidden(&self) -> bool {
self.is_hide_set()
}
/// Report if [`PossibleValue::hide`] is set
#[inline]
pub fn is_hide_set(&self) -> bool {
self.hide
}

View file

@ -26,6 +26,7 @@ impl Default for ArgFlags {
/// [`Arg::is_set`]: crate::Arg::is_set()
#[derive(Debug, PartialEq, Copy, Clone)]
#[non_exhaustive]
// TODO: Deprecate
pub enum ArgSettings {
/// Specifies that an arg must be used
Required,

View file

@ -171,7 +171,7 @@ impl<'help> UsageParser<'help> {
if dot_counter == 3 {
debug!("UsageParser::multiple: setting multiple");
arg.settings.set(ArgSettings::MultipleOccurrences);
if arg.is_set(ArgSettings::TakesValue) {
if arg.is_takes_value_set() {
arg.settings.set(ArgSettings::MultipleValues);
arg.settings.set(ArgSettings::UseValueDelimiter);
arg.val_delim.get_or_insert(',');
@ -253,7 +253,7 @@ mod test {
assert_eq!(a.short.unwrap(), 'f');
assert!(a.long.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_multiple_occurrences_set());
assert!(a.val_names.is_empty());
let a = Arg::from_usage("[flag] --flag 'some help info'");
@ -261,7 +261,7 @@ mod test {
assert_eq!(a.long.unwrap(), "flag");
assert!(a.short.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_multiple_occurrences_set());
assert!(a.val_names.is_empty());
let a = Arg::from_usage("--flag 'some help info'");
@ -269,7 +269,7 @@ mod test {
assert_eq!(a.long.unwrap(), "flag");
assert!(a.short.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_multiple_occurrences_set());
assert!(a.val_names.is_empty());
let a = Arg::from_usage("[flag] -f --flag 'some help info'");
@ -277,7 +277,7 @@ mod test {
assert_eq!(a.short.unwrap(), 'f');
assert_eq!(a.long.unwrap(), "flag");
assert_eq!(a.help.unwrap(), "some help info");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_multiple_occurrences_set());
assert!(a.val_names.is_empty());
let a = Arg::from_usage("[flag] -f... 'some help info'");
@ -285,7 +285,7 @@ mod test {
assert_eq!(a.short.unwrap(), 'f');
assert!(a.long.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.is_multiple_occurrences_set());
assert!(a.val_names.is_empty());
let a = Arg::from_usage("[flag] -f --flag... 'some help info'");
@ -293,7 +293,7 @@ mod test {
assert_eq!(a.long.unwrap(), "flag");
assert_eq!(a.short.unwrap(), 'f');
assert_eq!(a.help.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.is_multiple_occurrences_set());
assert!(a.val_names.is_empty());
let a = Arg::from_usage("-f --flag... 'some help info'");
@ -301,7 +301,7 @@ mod test {
assert_eq!(a.long.unwrap(), "flag");
assert_eq!(a.short.unwrap(), 'f');
assert_eq!(a.help.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.is_multiple_occurrences_set());
assert!(a.val_names.is_empty());
let a = Arg::from_usage("--flags");
@ -312,7 +312,7 @@ mod test {
let a = Arg::from_usage("--flags...");
assert_eq!(a.name, "flags");
assert_eq!(a.long.unwrap(), "flags");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.is_multiple_occurrences_set());
assert!(a.val_names.is_empty());
let a = Arg::from_usage("[flags] -f");
@ -323,7 +323,7 @@ mod test {
let a = Arg::from_usage("[flags] -f...");
assert_eq!(a.name, "flags");
assert_eq!(a.short.unwrap(), 'f');
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.is_multiple_occurrences_set());
assert!(a.val_names.is_empty());
let a = Arg::from_usage("-f 'some help info'");
@ -331,7 +331,7 @@ mod test {
assert_eq!(a.short.unwrap(), 'f');
assert!(a.long.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_multiple_occurrences_set());
assert!(a.val_names.is_empty());
let a = Arg::from_usage("-f");
@ -342,7 +342,7 @@ mod test {
let a = Arg::from_usage("-f...");
assert_eq!(a.name, "f");
assert_eq!(a.short.unwrap(), 'f');
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.is_multiple_occurrences_set());
assert!(a.val_names.is_empty());
}
@ -354,10 +354,10 @@ mod test {
assert_eq!(a.short.unwrap(), 'o');
assert!(a.long.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(!a.is_set(ArgSettings::Required));
assert!(!a.is_multiple_occurrences_set());
assert!(!a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(!a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"opt"]);
}
@ -368,10 +368,10 @@ mod test {
assert_eq!(a.short.unwrap(), 'o');
assert!(a.long.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(!a.is_set(ArgSettings::Required));
assert!(!a.is_multiple_occurrences_set());
assert!(!a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(!a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"opt"]);
}
@ -382,10 +382,10 @@ mod test {
assert_eq!(a.short.unwrap(), 'o');
assert!(a.long.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(a.is_set(ArgSettings::Required));
assert!(!a.is_multiple_occurrences_set());
assert!(!a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"opt"]);
}
@ -396,10 +396,10 @@ mod test {
assert_eq!(a.short.unwrap(), 'o');
assert!(a.long.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(a.is_set(ArgSettings::Required));
assert!(!a.is_multiple_occurrences_set());
assert!(!a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"opt"]);
}
@ -410,10 +410,10 @@ mod test {
assert_eq!(a.short.unwrap(), 'o');
assert!(a.long.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(!a.is_set(ArgSettings::Required));
assert!(a.is_multiple_occurrences_set());
assert!(a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(!a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"opt"]);
}
@ -424,10 +424,10 @@ mod test {
assert_eq!(a.short.unwrap(), 'o');
assert!(a.long.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(!a.is_set(ArgSettings::Required));
assert!(a.is_multiple_occurrences_set());
assert!(!a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(!a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"opt"]);
}
@ -438,10 +438,10 @@ mod test {
assert_eq!(a.short.unwrap(), 'o');
assert!(a.long.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(!a.is_set(ArgSettings::Required));
assert!(a.is_multiple_occurrences_set());
assert!(a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(!a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"opt"]);
}
@ -452,10 +452,10 @@ mod test {
assert_eq!(a.short.unwrap(), 'o');
assert!(a.long.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(a.is_set(ArgSettings::Required));
assert!(a.is_multiple_occurrences_set());
assert!(a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"opt"]);
}
@ -466,10 +466,10 @@ mod test {
assert_eq!(a.short.unwrap(), 'o');
assert!(a.long.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(a.is_set(ArgSettings::Required));
assert!(a.is_multiple_occurrences_set());
assert!(!a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"opt"]);
}
@ -480,10 +480,10 @@ mod test {
assert_eq!(a.short.unwrap(), 'o');
assert!(a.long.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(a.is_set(ArgSettings::Required));
assert!(a.is_multiple_occurrences_set());
assert!(a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"opt"]);
}
@ -494,10 +494,10 @@ mod test {
assert_eq!(a.long.unwrap(), "opt");
assert!(a.short.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(!a.is_set(ArgSettings::Required));
assert!(!a.is_multiple_occurrences_set());
assert!(!a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(!a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"opt"]);
}
@ -508,10 +508,10 @@ mod test {
assert_eq!(a.long.unwrap(), "opt");
assert!(a.short.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(!a.is_set(ArgSettings::Required));
assert!(!a.is_multiple_occurrences_set());
assert!(!a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(!a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"option"]);
}
@ -522,10 +522,10 @@ mod test {
assert_eq!(a.long.unwrap(), "opt");
assert!(a.short.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(a.is_set(ArgSettings::Required));
assert!(!a.is_multiple_occurrences_set());
assert!(!a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"opt"]);
}
@ -536,10 +536,10 @@ mod test {
assert_eq!(a.long.unwrap(), "opt");
assert!(a.short.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(a.is_set(ArgSettings::Required));
assert!(!a.is_multiple_occurrences_set());
assert!(!a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"option"]);
}
@ -550,10 +550,10 @@ mod test {
assert_eq!(a.long.unwrap(), "opt");
assert!(a.short.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(!a.is_set(ArgSettings::Required));
assert!(a.is_multiple_occurrences_set());
assert!(a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(!a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"opt"]);
}
@ -564,10 +564,10 @@ mod test {
assert_eq!(a.long.unwrap(), "opt");
assert!(a.short.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(!a.is_set(ArgSettings::Required));
assert!(a.is_multiple_occurrences_set());
assert!(!a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(!a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"opt"]);
}
@ -578,10 +578,10 @@ mod test {
assert_eq!(a.long.unwrap(), "opt");
assert!(a.short.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(!a.is_set(ArgSettings::Required));
assert!(a.is_multiple_occurrences_set());
assert!(a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(!a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"option"]);
}
@ -592,10 +592,10 @@ mod test {
assert_eq!(a.long.unwrap(), "opt");
assert!(a.short.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(a.is_set(ArgSettings::Required));
assert!(a.is_multiple_occurrences_set());
assert!(a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"opt"]);
}
@ -606,10 +606,10 @@ mod test {
assert_eq!(a.long.unwrap(), "opt");
assert!(a.short.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(a.is_set(ArgSettings::Required));
assert!(a.is_multiple_occurrences_set());
assert!(!a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"opt"]);
}
@ -620,10 +620,10 @@ mod test {
assert_eq!(a.long.unwrap(), "opt");
assert!(a.short.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(a.is_set(ArgSettings::Required));
assert!(a.is_multiple_occurrences_set());
assert!(a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"option"]);
}
@ -634,10 +634,10 @@ mod test {
assert_eq!(a.long.unwrap(), "opt");
assert!(a.short.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(!a.is_set(ArgSettings::Required));
assert!(!a.is_multiple_occurrences_set());
assert!(!a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(!a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"opt"]);
}
@ -648,10 +648,10 @@ mod test {
assert_eq!(a.long.unwrap(), "opt");
assert!(a.short.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(!a.is_set(ArgSettings::Required));
assert!(!a.is_multiple_occurrences_set());
assert!(!a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(!a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"option"]);
}
@ -662,10 +662,10 @@ mod test {
assert_eq!(a.long.unwrap(), "opt");
assert!(a.short.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(a.is_set(ArgSettings::Required));
assert!(!a.is_multiple_occurrences_set());
assert!(!a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"opt"]);
}
@ -676,10 +676,10 @@ mod test {
assert_eq!(a.long.unwrap(), "opt");
assert!(a.short.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(a.is_set(ArgSettings::Required));
assert!(!a.is_multiple_occurrences_set());
assert!(!a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"option"]);
}
@ -690,10 +690,10 @@ mod test {
assert_eq!(a.long.unwrap(), "opt");
assert!(a.short.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(!a.is_set(ArgSettings::Required));
assert!(a.is_multiple_occurrences_set());
assert!(a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(!a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"opt"]);
}
@ -704,10 +704,10 @@ mod test {
assert_eq!(a.long.unwrap(), "opt");
assert!(a.short.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(!a.is_set(ArgSettings::Required));
assert!(a.is_multiple_occurrences_set());
assert!(!a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(!a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"opt"]);
}
@ -718,10 +718,10 @@ mod test {
assert_eq!(a.long.unwrap(), "opt");
assert!(a.short.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(!a.is_set(ArgSettings::Required));
assert!(a.is_multiple_occurrences_set());
assert!(a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(!a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"option"]);
}
@ -732,10 +732,10 @@ mod test {
assert_eq!(a.long.unwrap(), "opt");
assert!(a.short.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(a.is_set(ArgSettings::Required));
assert!(a.is_multiple_occurrences_set());
assert!(a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"opt"]);
}
@ -746,10 +746,10 @@ mod test {
assert_eq!(a.long.unwrap(), "opt");
assert!(a.short.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(a.is_set(ArgSettings::Required));
assert!(a.is_multiple_occurrences_set());
assert!(!a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"opt"]);
}
@ -760,10 +760,10 @@ mod test {
assert_eq!(a.long.unwrap(), "opt");
assert!(a.short.is_none());
assert_eq!(a.help.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(a.is_set(ArgSettings::Required));
assert!(a.is_multiple_occurrences_set());
assert!(a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"option"]);
}
@ -774,10 +774,10 @@ mod test {
assert_eq!(a.long.unwrap(), "opt");
assert_eq!(a.short.unwrap(), 'o');
assert_eq!(a.help.unwrap(), "some help info");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(!a.is_set(ArgSettings::Required));
assert!(!a.is_multiple_occurrences_set());
assert!(!a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(!a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"option"]);
}
@ -788,10 +788,10 @@ mod test {
assert_eq!(a.long.unwrap(), "opt");
assert_eq!(a.short.unwrap(), 'o');
assert_eq!(a.help.unwrap(), "some help info");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(!a.is_set(ArgSettings::Required));
assert!(!a.is_multiple_occurrences_set());
assert!(!a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(!a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"option"]);
}
@ -802,10 +802,10 @@ mod test {
assert_eq!(a.long.unwrap(), "opt");
assert_eq!(a.short.unwrap(), 'o');
assert_eq!(a.help.unwrap(), "some help info");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(a.is_set(ArgSettings::Required));
assert!(!a.is_multiple_occurrences_set());
assert!(!a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"opt"]);
}
@ -816,10 +816,10 @@ mod test {
assert_eq!(a.long.unwrap(), "opt");
assert_eq!(a.short.unwrap(), 'o');
assert_eq!(a.help.unwrap(), "some help info");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(a.is_set(ArgSettings::Required));
assert!(!a.is_multiple_occurrences_set());
assert!(!a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"option"]);
}
@ -830,10 +830,10 @@ mod test {
assert_eq!(a.long.unwrap(), "opt");
assert_eq!(a.short.unwrap(), 'o');
assert_eq!(a.help.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(!a.is_set(ArgSettings::Required));
assert!(a.is_multiple_occurrences_set());
assert!(!a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(!a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"option"]);
}
@ -844,10 +844,10 @@ mod test {
assert_eq!(a.long.unwrap(), "opt");
assert_eq!(a.short.unwrap(), 'o');
assert_eq!(a.help.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(!a.is_set(ArgSettings::Required));
assert!(a.is_multiple_occurrences_set());
assert!(a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(!a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"option"]);
}
@ -858,10 +858,10 @@ mod test {
assert_eq!(a.long.unwrap(), "opt");
assert_eq!(a.short.unwrap(), 'o');
assert_eq!(a.help.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(a.is_set(ArgSettings::Required));
assert!(a.is_multiple_occurrences_set());
assert!(!a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"opt"]);
}
@ -872,10 +872,10 @@ mod test {
assert_eq!(a.long.unwrap(), "opt");
assert_eq!(a.short.unwrap(), 'o');
assert_eq!(a.help.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(a.is_set(ArgSettings::Required));
assert!(a.is_multiple_occurrences_set());
assert!(a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"option"]);
}
@ -886,10 +886,10 @@ mod test {
assert_eq!(a.long.unwrap(), "opt");
assert_eq!(a.short.unwrap(), 'o');
assert_eq!(a.help.unwrap(), "some help info");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(!a.is_set(ArgSettings::Required));
assert!(!a.is_multiple_occurrences_set());
assert!(!a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(!a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"option"]);
}
@ -900,10 +900,10 @@ mod test {
assert_eq!(a.long.unwrap(), "opt");
assert_eq!(a.short.unwrap(), 'o');
assert_eq!(a.help.unwrap(), "some help info");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(!a.is_set(ArgSettings::Required));
assert!(!a.is_multiple_occurrences_set());
assert!(!a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(!a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"option"]);
}
@ -914,10 +914,10 @@ mod test {
assert_eq!(a.long.unwrap(), "opt");
assert_eq!(a.short.unwrap(), 'o');
assert_eq!(a.help.unwrap(), "some help info");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(a.is_set(ArgSettings::Required));
assert!(!a.is_multiple_occurrences_set());
assert!(!a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"opt"]);
}
@ -928,10 +928,10 @@ mod test {
assert_eq!(a.long.unwrap(), "opt");
assert_eq!(a.short.unwrap(), 'o');
assert_eq!(a.help.unwrap(), "some help info");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(a.is_set(ArgSettings::Required));
assert!(!a.is_multiple_occurrences_set());
assert!(!a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"option"]);
}
@ -942,10 +942,10 @@ mod test {
assert_eq!(a.long.unwrap(), "opt");
assert_eq!(a.short.unwrap(), 'o');
assert_eq!(a.help.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(!a.is_set(ArgSettings::Required));
assert!(a.is_multiple_occurrences_set());
assert!(!a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(!a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"option"]);
}
@ -956,10 +956,10 @@ mod test {
assert_eq!(a.long.unwrap(), "opt");
assert_eq!(a.short.unwrap(), 'o');
assert_eq!(a.help.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(!a.is_set(ArgSettings::Required));
assert!(a.is_multiple_occurrences_set());
assert!(a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(!a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"option"]);
}
@ -970,10 +970,10 @@ mod test {
assert_eq!(a.long.unwrap(), "opt");
assert_eq!(a.short.unwrap(), 'o');
assert_eq!(a.help.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(a.is_set(ArgSettings::Required));
assert!(a.is_multiple_occurrences_set());
assert!(!a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"opt"]);
}
@ -984,10 +984,10 @@ mod test {
assert_eq!(a.long.unwrap(), "opt");
assert_eq!(a.short.unwrap(), 'o');
assert_eq!(a.help.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(a.is_set(ArgSettings::Required));
assert!(a.is_multiple_occurrences_set());
assert!(a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"option"]);
}
@ -998,10 +998,10 @@ mod test {
assert!(a.long.is_none());
assert_eq!(a.short.unwrap(), 'o');
assert_eq!(a.help.unwrap(), "some help info");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(a.is_set(ArgSettings::Required));
assert!(!a.is_multiple_occurrences_set());
assert!(!a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"file", &"mode"]);
}
@ -1012,10 +1012,10 @@ mod test {
assert!(a.long.is_none());
assert_eq!(a.short.unwrap(), 'o');
assert_eq!(a.help.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(a.is_set(ArgSettings::Required));
assert!(a.is_multiple_occurrences_set());
assert!(a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"file", &"mode"]);
}
@ -1026,10 +1026,10 @@ mod test {
assert!(a.short.is_none());
assert_eq!(a.long.unwrap(), "opt");
assert_eq!(a.help.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(a.is_set(ArgSettings::Required));
assert!(a.is_multiple_occurrences_set());
assert!(a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"file", &"mode"]);
}
@ -1040,10 +1040,10 @@ mod test {
assert!(a.short.is_none());
assert_eq!(a.long.unwrap(), "opt");
assert_eq!(a.help.unwrap(), "some help info");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(!a.is_set(ArgSettings::Required));
assert!(!a.is_multiple_occurrences_set());
assert!(!a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(!a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"file", &"mode"]);
}
@ -1054,10 +1054,10 @@ mod test {
assert!(a.short.is_none());
assert_eq!(a.long.unwrap(), "opt");
assert_eq!(a.help.unwrap(), "some help info");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(a.is_set(ArgSettings::Required));
assert!(!a.is_multiple_occurrences_set());
assert!(!a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(a.is_required_set());
}
#[test]
@ -1065,9 +1065,9 @@ mod test {
let a = Arg::from_usage("[pos] 'some help info'");
assert_eq!(a.name, "pos");
assert_eq!(a.help.unwrap(), "some help info");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(!a.is_set(ArgSettings::Required));
assert!(!a.is_multiple_occurrences_set());
assert!(!a.is_multiple_values_set());
assert!(!a.is_required_set());
assert!(a.val_names.is_empty());
}
@ -1076,9 +1076,9 @@ mod test {
let a = Arg::from_usage("<pos> 'some help info'");
assert_eq!(a.name, "pos");
assert_eq!(a.help.unwrap(), "some help info");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::Required));
assert!(!a.is_multiple_occurrences_set());
assert!(!a.is_multiple_values_set());
assert!(a.is_required_set());
assert!(a.val_names.is_empty());
}
@ -1087,9 +1087,9 @@ mod test {
let a = Arg::from_usage("[pos]... 'some help info'");
assert_eq!(a.name, "pos");
assert_eq!(a.help.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(!a.is_set(ArgSettings::Required));
assert!(a.is_multiple_occurrences_set());
assert!(!a.is_multiple_values_set());
assert!(!a.is_required_set());
assert!(a.val_names.is_empty());
}
@ -1098,9 +1098,9 @@ mod test {
let a = Arg::from_usage("[pos]... 'some help\' info'");
assert_eq!(a.name, "pos");
assert_eq!(a.help.unwrap(), "some help' info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(!a.is_set(ArgSettings::Required));
assert!(a.is_multiple_occurrences_set());
assert!(!a.is_multiple_values_set());
assert!(!a.is_required_set());
assert!(a.val_names.is_empty());
}
@ -1109,9 +1109,9 @@ mod test {
let a = Arg::from_usage("[pos]... 'some \'help\' info'");
assert_eq!(a.name, "pos");
assert_eq!(a.help.unwrap(), "some 'help' info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(!a.is_set(ArgSettings::Required));
assert!(a.is_multiple_occurrences_set());
assert!(!a.is_multiple_values_set());
assert!(!a.is_required_set());
assert!(a.val_names.is_empty());
}
@ -1123,9 +1123,9 @@ mod test {
);
assert_eq!(a.name, "pos");
assert_eq!(a.help.unwrap(), "some help{n}info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(!a.is_set(ArgSettings::Required));
assert!(a.is_multiple_occurrences_set());
assert!(!a.is_multiple_values_set());
assert!(!a.is_required_set());
assert!(a.val_names.is_empty());
}
@ -1137,9 +1137,9 @@ mod test {
);
assert_eq!(a.name, "pos");
assert_eq!(a.help.unwrap(), "some help' stuff{n}info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(!a.is_set(ArgSettings::Required));
assert!(a.is_multiple_occurrences_set());
assert!(!a.is_multiple_values_set());
assert!(!a.is_required_set());
assert!(a.val_names.is_empty());
}
@ -1148,9 +1148,9 @@ mod test {
let a = Arg::from_usage("<pos>... 'some help info'");
assert_eq!(a.name, "pos");
assert_eq!(a.help.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::Required));
assert!(a.is_multiple_occurrences_set());
assert!(!a.is_multiple_values_set());
assert!(a.is_required_set());
assert!(a.val_names.is_empty());
}
@ -1158,9 +1158,9 @@ mod test {
fn pos_req() {
let a = Arg::from_usage("<pos>");
assert_eq!(a.name, "pos");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::Required));
assert!(!a.is_multiple_occurrences_set());
assert!(!a.is_multiple_values_set());
assert!(a.is_required_set());
assert!(a.val_names.is_empty());
}
@ -1168,9 +1168,9 @@ mod test {
fn pos_mult() {
let a = Arg::from_usage("[pos]...");
assert_eq!(a.name, "pos");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(!a.is_set(ArgSettings::Required));
assert!(a.is_multiple_occurrences_set());
assert!(!a.is_multiple_values_set());
assert!(!a.is_required_set());
assert!(a.val_names.is_empty());
}
@ -1179,9 +1179,9 @@ mod test {
let a = Arg::from_usage("<pos>... @a 'some help info'");
assert_eq!(a.name, "pos");
assert_eq!(a.help.unwrap(), "some help info");
assert!(a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::Required));
assert!(a.is_multiple_occurrences_set());
assert!(!a.is_multiple_values_set());
assert!(a.is_required_set());
assert!(a.val_names.is_empty());
assert_eq!(a.default_vals, vec![std::ffi::OsStr::new("a")]);
}
@ -1193,10 +1193,10 @@ mod test {
assert!(a.long.is_none());
assert_eq!(a.short.unwrap(), 'o');
assert_eq!(a.help.unwrap(), "some help info");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(a.is_set(ArgSettings::Required));
assert!(!a.is_multiple_occurrences_set());
assert!(!a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"file", &"mode"]);
assert_eq!(a.default_vals, vec![std::ffi::OsStr::new("a")]);
}
@ -1208,10 +1208,10 @@ mod test {
assert!(a.short.is_none());
assert_eq!(a.long.unwrap(), "opt");
assert_eq!(a.help.unwrap(), "some help info");
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
assert!(!a.is_set(ArgSettings::MultipleValues));
assert!(a.is_set(ArgSettings::TakesValue));
assert!(!a.is_set(ArgSettings::Required));
assert!(!a.is_multiple_occurrences_set());
assert!(!a.is_multiple_values_set());
assert!(a.is_takes_value_set());
assert!(!a.is_required_set());
assert_eq!(a.val_names.iter().collect::<Vec<_>>(), [&"file", &"mode"]);
assert_eq!(a.default_vals, vec![std::ffi::OsStr::new("a")]);
}

View file

@ -378,7 +378,7 @@ macro_rules! arg_impl {
@arg
({
debug_assert_eq!($arg.get_value_names(), None, "Flags should precede values");
debug_assert!(!$arg.is_set($crate::ArgSettings::MultipleOccurrences), "Flags should precede `...`");
debug_assert!(!$arg.is_multiple_occurrences_set(), "Flags should precede `...`");
let mut arg = $arg;
let long = $crate::arg_impl! { @string $long };
@ -400,7 +400,7 @@ macro_rules! arg_impl {
@arg
({
debug_assert_eq!($arg.get_value_names(), None, "Flags should precede values");
debug_assert!(!$arg.is_set($crate::ArgSettings::MultipleOccurrences), "Flags should precede `...`");
debug_assert!(!$arg.is_multiple_occurrences_set(), "Flags should precede `...`");
let mut arg = $arg;
let long = $crate::arg_impl! { @string $long };
@ -423,7 +423,7 @@ macro_rules! arg_impl {
({
debug_assert_eq!($arg.get_long(), None, "Short flags should precede long flags");
debug_assert_eq!($arg.get_value_names(), None, "Flags should precede values");
debug_assert!(!$arg.is_set($crate::ArgSettings::MultipleOccurrences), "Flags should precede `...`");
debug_assert!(!$arg.is_multiple_occurrences_set(), "Flags should precede `...`");
$arg.short($crate::arg_impl! { @char $short })
})
@ -441,7 +441,7 @@ macro_rules! arg_impl {
({
debug_assert_eq!($arg.get_long(), None, "Short flags should precede long flags");
debug_assert_eq!($arg.get_value_names(), None, "Flags should precede values");
debug_assert!(!$arg.is_set($crate::ArgSettings::MultipleOccurrences), "Flags should precede `...`");
debug_assert!(!$arg.is_multiple_occurrences_set(), "Flags should precede `...`");
$arg.short($crate::arg_impl! { @char $short })
})
@ -457,7 +457,7 @@ macro_rules! arg_impl {
$crate::arg_impl! {
@arg
({
debug_assert!(!$arg.is_set($crate::ArgSettings::MultipleOccurrences), "Values should precede `...`");
debug_assert!(!$arg.is_multiple_occurrences_set(), "Values should precede `...`");
debug_assert_eq!($arg.get_value_names(), None, "Multiple values not yet supported");
let mut arg = $arg;
@ -483,7 +483,7 @@ macro_rules! arg_impl {
$crate::arg_impl! {
@arg
({
debug_assert!(!$arg.is_set($crate::ArgSettings::MultipleOccurrences), "Values should precede `...`");
debug_assert!(!$arg.is_multiple_occurrences_set(), "Values should precede `...`");
debug_assert_eq!($arg.get_value_names(), None, "Multiple values not yet supported");
let mut arg = $arg;

View file

@ -9,7 +9,7 @@ use std::{
// Internal
use crate::{
build::{arg::display_arg_val, App, AppSettings, Arg, ArgSettings},
build::{arg::display_arg_val, App, AppSettings, Arg},
output::{fmt::Colorizer, Usage},
};
@ -282,9 +282,9 @@ impl<'help, 'app, 'writer> Help<'help, 'app, 'writer> {
fn val(&mut self, arg: &Arg<'help>) -> io::Result<()> {
debug!("Help::val: arg={}", arg.name);
let mut need_closing_bracket = false;
if arg.is_set(ArgSettings::TakesValue) && !arg.is_positional() {
if arg.is_takes_value_set() && !arg.is_positional() {
let is_optional_val = arg.min_vals == Some(0);
let sep = if arg.is_set(ArgSettings::RequireEquals) {
let sep = if arg.is_require_equals_set() {
if is_optional_val {
need_closing_bracket = true;
"[="
@ -300,7 +300,7 @@ impl<'help, 'app, 'writer> Help<'help, 'app, 'writer> {
self.none(sep)?;
}
if arg.is_set(ArgSettings::TakesValue) || arg.is_positional() {
if arg.is_takes_value_set() || arg.is_positional() {
display_arg_val(
arg,
|s, good| if good { self.good(s) } else { self.none(s) },
@ -476,7 +476,7 @@ impl<'help, 'app, 'writer> Help<'help, 'app, 'writer> {
}
fn arg_next_line_help(&self, arg: &Arg<'help>, spec_vals: &str, longest: usize) -> bool {
if self.next_line_help || arg.is_set(ArgSettings::NextLineHelp) || self.use_long {
if self.next_line_help || arg.is_next_line_help_set() || self.use_long {
// setting_next_line
true
} else {
@ -495,12 +495,12 @@ impl<'help, 'app, 'writer> Help<'help, 'app, 'writer> {
let mut spec_vals = vec![];
#[cfg(feature = "env")]
if let Some(ref env) = a.env {
if !a.is_set(ArgSettings::HideEnv) {
if !a.is_hide_env_set() {
debug!(
"Help::spec_vals: Found environment variable...[{:?}:{:?}]",
env.0, env.1
);
let env_val = if !a.is_set(ArgSettings::HideEnvValues) {
let env_val = if !a.is_hide_env_values_set() {
format!(
"={}",
env.1
@ -514,7 +514,7 @@ impl<'help, 'app, 'writer> Help<'help, 'app, 'writer> {
spec_vals.push(env_info);
}
}
if !a.is_set(ArgSettings::HideDefaultValue) && !a.default_vals.is_empty() {
if !a.is_hide_default_value_set() && !a.default_vals.is_empty() {
debug!(
"Help::spec_vals: Found default value...[{:?}]",
a.default_vals
@ -571,10 +571,7 @@ impl<'help, 'app, 'writer> Help<'help, 'app, 'writer> {
}
}
if !self.hide_pv
&& !a.is_set(ArgSettings::HidePossibleValues)
&& !a.possible_vals.is_empty()
{
if !self.hide_pv && !a.is_hide_possible_values_set() && !a.possible_vals.is_empty() {
debug!(
"Help::spec_vals: Found possible vals...{:?}",
a.possible_vals
@ -584,7 +581,7 @@ impl<'help, 'app, 'writer> Help<'help, 'app, 'writer> {
.possible_vals
.iter()
.filter_map(|value| {
if value.is_hidden() {
if value.is_hide_set() {
None
} else if value.get_name().contains(char::is_whitespace) {
Some(format!("{:?}", value.get_name()))
@ -999,12 +996,12 @@ pub(crate) enum HelpWriter<'writer> {
fn should_show_arg(use_long: bool, arg: &Arg) -> bool {
debug!("should_show_arg: use_long={:?}, arg={}", use_long, arg.name);
if arg.is_set(ArgSettings::Hidden) {
if arg.is_hide_set() {
return false;
}
(!arg.is_set(ArgSettings::HiddenLongHelp) && use_long)
|| (!arg.is_set(ArgSettings::HiddenShortHelp) && !use_long)
|| arg.is_set(ArgSettings::NextLineHelp)
(!arg.is_hide_long_help_set() && use_long)
|| (!arg.is_hide_short_help_set() && !use_long)
|| arg.is_next_line_help_set()
}
fn should_show_subcommand(subcommand: &App) -> bool {

View file

@ -3,7 +3,7 @@ use indexmap::IndexSet;
// Internal
use crate::{
build::AppSettings as AS,
build::{App, Arg, ArgPredicate, ArgSettings},
build::{App, Arg, ArgPredicate},
parse::ArgMatcher,
util::{ChildGraph, Id},
INTERNAL_ERROR_MSG,
@ -69,30 +69,22 @@ impl<'help, 'app> Usage<'help, 'app> {
usage.push_str(&req_string);
}
let has_last = self
.app
.get_positionals()
.any(|p| p.is_set(ArgSettings::Last));
let has_last = self.app.get_positionals().any(|p| p.is_last_set());
// places a '--' in the usage string if there are args and options
// supporting multiple values
if self
.app
.get_non_positionals()
.any(|o| o.is_set(ArgSettings::MultipleValues))
&& self
.app
.get_positionals()
.any(|p| !p.is_set(ArgSettings::Required))
.any(|o| o.is_multiple_values_set())
&& self.app.get_positionals().any(|p| !p.is_required_set())
&& !(self.app.has_visible_subcommands()
|| self.app.is_set(AS::AllowExternalSubcommands))
&& !has_last
{
usage.push_str(" [--]");
}
let not_req_or_hidden = |p: &Arg| {
(!p.is_set(ArgSettings::Required) || p.is_set(ArgSettings::Last))
&& !p.is_set(ArgSettings::Hidden)
};
let not_req_or_hidden =
|p: &Arg| (!p.is_required_set() || p.is_last_set()) && !p.is_hide_set();
if self.app.get_positionals().any(not_req_or_hidden) {
if let Some(args_tag) = self.get_args_tag(incl_reqs) {
usage.push_str(&*args_tag);
@ -103,16 +95,11 @@ impl<'help, 'app> Usage<'help, 'app> {
let pos = self
.app
.get_positionals()
.find(|p| p.is_set(ArgSettings::Last))
.find(|p| p.is_last_set())
.expect(INTERNAL_ERROR_MSG);
debug!("Usage::create_help_usage: '{}' has .last(true)", pos.name);
let req = pos.is_set(ArgSettings::Required);
if req
&& self
.app
.get_positionals()
.any(|p| !p.is_set(ArgSettings::Required))
{
let req = pos.is_required_set();
if req && self.app.get_positionals().any(|p| !p.is_required_set()) {
usage.push_str(" -- <");
} else if req {
usage.push_str(" [--] <");
@ -202,9 +189,9 @@ impl<'help, 'app> Usage<'help, 'app> {
for pos in self
.app
.get_positionals()
.filter(|pos| !pos.is_set(ArgSettings::Required))
.filter(|pos| !pos.is_set(ArgSettings::Hidden))
.filter(|pos| !pos.is_set(ArgSettings::Last))
.filter(|pos| !pos.is_required_set())
.filter(|pos| !pos.is_hide_set())
.filter(|pos| !pos.is_last_set())
{
debug!("Usage::get_args_tag:iter:{}", pos.name);
let required = self.app.groups_for_arg(&pos.id).any(|grp_s| {
@ -234,9 +221,9 @@ impl<'help, 'app> Usage<'help, 'app> {
.app
.get_positionals()
.find(|pos| {
!pos.is_set(ArgSettings::Required)
&& !pos.is_set(ArgSettings::Hidden)
&& !pos.is_set(ArgSettings::Last)
!pos.is_required_set()
&& !pos.is_hide_set()
&& !pos.is_last_set()
&& !self.app.groups_for_arg(&pos.id).any(|grp_s| {
debug!("Usage::get_args_tag:iter:{:?}:iter:{:?}", pos.name, grp_s);
// if it's part of a required group we don't want to count it
@ -266,9 +253,9 @@ impl<'help, 'app> Usage<'help, 'app> {
Some(
self.app
.get_positionals()
.filter(|pos| !pos.is_set(ArgSettings::Required))
.filter(|pos| !pos.is_set(ArgSettings::Hidden))
.filter(|pos| !pos.is_set(ArgSettings::Last))
.filter(|pos| !pos.is_required_set())
.filter(|pos| !pos.is_hide_set())
.filter(|pos| !pos.is_last_set())
.map(|pos| format!(" [{}]{}", pos.name_no_brackets(), pos.multiple_str()))
.collect::<Vec<_>>()
.join(""),
@ -279,7 +266,7 @@ impl<'help, 'app> Usage<'help, 'app> {
.app
.get_positionals()
.filter_map(|pos| {
if pos.is_set(ArgSettings::Required) && !pos.is_set(ArgSettings::Last) {
if pos.is_required_set() && !pos.is_last_set() {
Some(pos.index)
} else {
None
@ -291,9 +278,9 @@ impl<'help, 'app> Usage<'help, 'app> {
self.app
.get_positionals()
.filter(|pos| pos.index <= highest_req_pos)
.filter(|pos| !pos.is_set(ArgSettings::Required))
.filter(|pos| !pos.is_set(ArgSettings::Hidden))
.filter(|pos| !pos.is_set(ArgSettings::Last))
.filter(|pos| !pos.is_required_set())
.filter(|pos| !pos.is_hide_set())
.filter(|pos| !pos.is_last_set())
.map(|pos| format!(" [{}]{}", pos.name_no_brackets(), pos.multiple_str()))
.collect::<Vec<_>>()
.join(""),
@ -315,11 +302,11 @@ impl<'help, 'app> Usage<'help, 'app> {
continue;
}
if f.is_set(ArgSettings::Hidden) {
if f.is_hide_set() {
debug!("Usage::needs_options_tag:iter Option is hidden");
continue;
}
if f.is_set(ArgSettings::Required) {
if f.is_required_set() {
debug!("Usage::needs_options_tag:iter Option is required");
continue;
}
@ -439,7 +426,7 @@ impl<'help, 'app> Usage<'help, 'app> {
.filter(|a| self.app.get_positionals().any(|p| &&p.id == a))
.filter(|&pos| matcher.map_or(true, |m| !m.contains(pos)))
.filter_map(|pos| self.app.find(pos))
.filter(|&pos| incl_last || !pos.is_set(ArgSettings::Last))
.filter(|&pos| incl_last || !pos.is_last_set())
.filter(|pos| !args_in_groups.contains(&pos.id))
.map(|pos| (pos.index.unwrap(), pos))
.collect::<Vec<(usize, &Arg)>>();

View file

@ -3,7 +3,7 @@ use std::{collections::HashMap, ffi::OsString, mem, ops::Deref};
// Internal
use crate::{
build::{App, Arg, ArgPredicate, ArgSettings},
build::{App, Arg, ArgPredicate},
parse::{ArgMatches, MatchedArg, SubCommand, ValueSource},
util::Id,
};
@ -130,8 +130,8 @@ impl ArgMatcher {
debug!("ArgMatcher::inc_occurrence_of_arg: id={:?}", id);
let ma = self.entry(id).or_insert(MatchedArg::new());
ma.update_ty(ValueSource::CommandLine);
ma.set_ignore_case(arg.is_set(ArgSettings::IgnoreCase));
ma.invalid_utf8_allowed(arg.is_set(ArgSettings::AllowInvalidUtf8));
ma.set_ignore_case(arg.is_ignore_case_set());
ma.invalid_utf8_allowed(arg.is_allow_invalid_utf8_set());
ma.inc_occurrences();
}
@ -189,7 +189,7 @@ impl ArgMatcher {
let current_num = ma.num_vals();
if let Some(num) = o.num_vals {
debug!("ArgMatcher::needs_more_vals: num_vals...{}", num);
return if o.is_set(ArgSettings::MultipleOccurrences) {
return if o.is_multiple_occurrences_set() {
(current_num % num) != 0
} else {
num != current_num
@ -201,7 +201,7 @@ impl ArgMatcher {
debug!("ArgMatcher::needs_more_vals: min_vals...true");
return true;
}
return o.is_set(ArgSettings::MultipleValues);
return o.is_multiple_values_set();
}
true
}

View file

@ -830,7 +830,7 @@ impl ArgMatches {
/// let m = App::new("myapp")
/// .arg(Arg::new("option")
/// .short('o')
/// .use_delimiter(true)
/// .use_value_delimiter(true)
/// .multiple_values(true))
/// .get_matches_from(vec!["myapp", "-o=val1,val2,val3"]);
/// // ARGV indices: ^0 ^1
@ -871,7 +871,7 @@ impl ArgMatches {
/// let m = App::new("myapp")
/// .arg(Arg::new("option")
/// .short('o')
/// .use_delimiter(true)
/// .use_value_delimiter(true)
/// .multiple_values(true))
/// .get_matches_from(vec!["myapp", "-o=val1,val2,val3"]);
/// // ARGV indices: ^0 ^1

View file

@ -10,7 +10,7 @@ use os_str_bytes::RawOsStr;
// Internal
use crate::build::AppSettings as AS;
use crate::build::{App, Arg, ArgSettings};
use crate::build::{App, Arg};
use crate::error::Error as ClapError;
use crate::error::Result as ClapResult;
use crate::mkeymap::KeyType;
@ -38,11 +38,7 @@ pub(crate) struct Parser<'help, 'app> {
impl<'help, 'app> Parser<'help, 'app> {
pub(crate) fn new(app: &'app mut App<'help>) -> Self {
let mut reqs = ChildGraph::with_capacity(5);
for a in app
.args
.args()
.filter(|a| a.settings.is_set(ArgSettings::Required))
{
for a in app.args.args().filter(|a| a.is_required_set()) {
reqs.insert(a.id.clone());
}
for group in &app.groups {
@ -101,7 +97,7 @@ impl<'help, 'app> Parser<'help, 'app> {
// Count of positional args
let positional_count = self.app.args.keys().filter(|x| x.is_position()).count();
// If any arg sets .last(true)
let contains_last = self.app.args.args().any(|x| x.is_set(ArgSettings::Last));
let contains_last = self.app.args.args().any(|x| x.is_last_set());
while let Some((arg_os, remaining_args)) = it.next() {
// Recover the replaced items if any.
@ -141,7 +137,7 @@ impl<'help, 'app> Parser<'help, 'app> {
.app
.get_positionals()
.last()
.map_or(false, |p_name| !p_name.is_set(ArgSettings::Last));
.map_or(false, |p_name| !p_name.is_last_set());
let missing_pos = self.is_set(AS::AllowMissingPositional)
&& is_second_to_last
@ -391,7 +387,7 @@ impl<'help, 'app> Parser<'help, 'app> {
}
if let Some(p) = self.app.args.get(&pos_counter) {
if p.is_set(ArgSettings::Last) && !trailing_values {
if p.is_last_set() && !trailing_values {
return Err(ClapError::unknown_argument(
self.app,
arg_os.to_str_lossy().into_owned(),
@ -673,7 +669,7 @@ impl<'help, 'app> Parser<'help, 'app> {
);
if self.is_set(AS::AllowHyphenValues)
|| self.app[&current_positional.id].is_set(ArgSettings::AllowHyphenValues)
|| self.app[&current_positional.id].is_allow_hyphen_values_set()
|| (self.is_set(AS::AllowNegativeNumbers) && next.to_str_lossy().parse::<f64>().is_ok())
{
// If allow hyphen, this isn't a new arg.
@ -858,12 +854,10 @@ impl<'help, 'app> Parser<'help, 'app> {
debug!("Parser::use_long_help");
// In this case, both must be checked. This allows the retention of
// original formatting, but also ensures that the actual -h or --help
// specified by the user is sent through. If HiddenShortHelp is not included,
// specified by the user is sent through. If hide_short_help is not included,
// then items specified with hidden_short_help will also be hidden.
let should_long = |v: &Arg| {
v.long_help.is_some()
|| v.is_set(ArgSettings::HiddenLongHelp)
|| v.is_set(ArgSettings::HiddenShortHelp)
v.long_help.is_some() || v.is_hide_long_help_set() || v.is_hide_short_help_set()
};
// Subcommands aren't checked because we prefer short help for them, deferring to
@ -886,7 +880,7 @@ impl<'help, 'app> Parser<'help, 'app> {
debug!("Parser::parse_long_arg");
if matches!(parse_state, ParseState::Opt(opt) | ParseState::Pos(opt) if
self.app[opt].is_set(ArgSettings::AllowHyphenValues))
self.app[opt].is_allow_hyphen_values_set())
{
return ParseResult::MaybeHyphenValue;
}
@ -929,7 +923,7 @@ impl<'help, 'app> Parser<'help, 'app> {
if let Some(opt) = opt {
*valid_arg_found = true;
self.seen.push(opt.id.clone());
if opt.is_set(ArgSettings::TakesValue) {
if opt.is_takes_value_set() {
debug!(
"Parser::parse_long_arg: Found an opt with value '{:?}'",
&val
@ -941,7 +935,7 @@ impl<'help, 'app> Parser<'help, 'app> {
.arg_names()
.filter(|&n| {
self.app.find(n).map_or(true, |a| {
!(a.is_set(ArgSettings::Hidden) || self.required.contains(&a.id))
!(a.is_hide_set() || self.required.contains(&a.id))
})
})
.cloned()
@ -992,12 +986,12 @@ impl<'help, 'app> Parser<'help, 'app> {
debug!("Parser::parse_short_args: contains non-short flag");
return ParseResult::MaybeHyphenValue;
} else if matches!(parse_state, ParseState::Opt(opt) | ParseState::Pos(opt)
if self.app[opt].is_set(ArgSettings::AllowHyphenValues))
if self.app[opt].is_allow_hyphen_values_set())
{
debug!("Parser::parse_short_args: prior arg accepts hyphenated values",);
return ParseResult::MaybeHyphenValue;
} else if self.app.args.get(&pos_counter).map_or(false, |arg| {
arg.is_set(ArgSettings::AllowHyphenValues) && !arg.is_set(ArgSettings::Last)
arg.is_allow_hyphen_values_set() && !arg.is_last_set()
}) {
debug!(
"Parser::parse_short_args: positional at {} allows hyphens",
@ -1032,7 +1026,7 @@ impl<'help, 'app> Parser<'help, 'app> {
);
*valid_arg_found = true;
self.seen.push(opt.id.clone());
if !opt.is_set(ArgSettings::TakesValue) {
if !opt.is_takes_value_set() {
if let Some(parse_result) = self.check_for_help_and_version_char(c) {
return parse_result;
}
@ -1053,7 +1047,7 @@ impl<'help, 'app> Parser<'help, 'app> {
// If attached value is not consumed, we may have more short
// flags to parse, continue.
//
// e.g. `-xvf`, when RequireEquals && x.min_vals == 0, we don't
// e.g. `-xvf`, when require_equals && x.min_vals == 0, we don't
// consume the `vf`, even if it's provided as value.
match self.parse_opt(val, opt, matcher, trailing_values) {
ParseResult::AttachedValueNotConsumed => continue,
@ -1104,8 +1098,8 @@ impl<'help, 'app> Parser<'help, 'app> {
let has_eq = matches!(attached_value, Some(fv) if fv.starts_with("="));
debug!("Parser::parse_opt; Checking for val...");
// RequireEquals is set, but no '=' is provided, try throwing error.
if opt.is_set(ArgSettings::RequireEquals) && !has_eq {
// require_equals is set, but no '=' is provided, try throwing error.
if opt.is_require_equals_set() && !has_eq {
if opt.min_vals == Some(0) {
debug!("Requires equals, but min_vals == 0");
self.inc_occurrence_of_arg(matcher, opt);
@ -1187,7 +1181,7 @@ impl<'help, 'app> Parser<'help, 'app> {
// separate the values or no more vals is needed, we're not
// looking for more values.
return if val.contains(delim)
|| arg.is_set(ArgSettings::RequireDelimiter)
|| arg.is_require_value_delimiter_set()
|| !matcher.needs_more_vals(arg)
{
ParseResult::ValuesDone
@ -1448,7 +1442,7 @@ impl<'help, 'app> Parser<'help, 'app> {
if let Some((_, Some(ref val))) = a.env {
let val = RawOsStr::new(val);
if a.is_set(ArgSettings::TakesValue) {
if a.is_takes_value_set() {
debug!(
"Parser::add_env: Found an opt with value={:?}, trailing={:?}",
val, trailing_values
@ -1541,7 +1535,7 @@ impl<'help, 'app> Parser<'help, 'app> {
.arg_names()
.filter(|n| {
self.app.find(n).map_or(true, |a| {
!(self.required.contains(&a.id) || a.is_set(ArgSettings::Hidden))
!(self.required.contains(&a.id) || a.is_hide_set())
})
})
.cloned()

View file

@ -1,5 +1,5 @@
// Internal
use crate::build::{arg::PossibleValue, App, AppSettings as AS, Arg, ArgPredicate, ArgSettings};
use crate::build::{arg::PossibleValue, App, AppSettings as AS, Arg, ArgPredicate};
use crate::error::{Error, Result as ClapResult};
use crate::output::Usage;
use crate::parse::{ArgMatcher, MatchedArg, ParseState, Parser};
@ -82,7 +82,7 @@ impl<'help, 'app, 'parser> Validator<'help, 'app, 'parser> {
) -> ClapResult<()> {
debug!("Validator::validate_arg_values: arg={:?}", arg.name);
for val in ma.vals_flatten() {
if !arg.is_set(ArgSettings::AllowInvalidUtf8) && val.to_str().is_none() {
if !arg.is_allow_invalid_utf8_set() && val.to_str().is_none() {
debug!(
"Validator::validate_arg_values: invalid UTF-8 found in val {:?}",
val
@ -101,14 +101,14 @@ impl<'help, 'app, 'parser> Validator<'help, 'app, 'parser> {
let ok = arg
.possible_vals
.iter()
.any(|pv| pv.matches(&val_str, arg.is_set(ArgSettings::IgnoreCase)));
.any(|pv| pv.matches(&val_str, arg.is_ignore_case_set()));
if !ok {
let used: Vec<Id> = matcher
.arg_names()
.filter(|arg_id| matcher.check_explicit(arg_id, ArgPredicate::IsPresent))
.filter(|&n| {
self.p.app.find(n).map_or(true, |a| {
!(a.is_set(ArgSettings::Hidden) || self.p.required.contains(&a.id))
!(a.is_hide_set() || self.p.required.contains(&a.id))
})
})
.cloned()
@ -125,10 +125,7 @@ impl<'help, 'app, 'parser> Validator<'help, 'app, 'parser> {
));
}
}
if arg.is_set(ArgSettings::ForbidEmptyValues)
&& val.is_empty()
&& matcher.contains(&arg.id)
{
if arg.is_forbid_empty_values_set() && val.is_empty() && matcher.contains(&arg.id) {
debug!("Validator::validate_arg_values: illegal empty val found");
return Err(Error::empty_value(
self.p.app,
@ -206,7 +203,7 @@ impl<'help, 'app, 'parser> Validator<'help, 'app, 'parser> {
.app
.find(name)
// Find `arg`s which are exclusive but also appear with other args.
.filter(|&arg| arg.is_set(ArgSettings::Exclusive) && args_count > 1)
.filter(|&arg| arg.is_exclusive_set() && args_count > 1)
})
// Throw an error for the first conflict found.
.try_for_each(|arg| {
@ -323,10 +320,7 @@ impl<'help, 'app, 'parser> Validator<'help, 'app, 'parser> {
);
// Occurrence of positional argument equals to number of values rather
// than number of grouped values.
if ma.get_occurrences() > 1
&& !a.is_set(ArgSettings::MultipleOccurrences)
&& !a.is_positional()
{
if ma.get_occurrences() > 1 && !a.is_multiple_occurrences_set() && !a.is_positional() {
// Not the first time, and we don't allow multiples
return Err(Error::unexpected_multiple_usage(
self.p.app,
@ -359,7 +353,7 @@ impl<'help, 'app, 'parser> Validator<'help, 'app, 'parser> {
if let Some(num) = a.num_vals {
let total_num = ma.num_vals();
debug!("Validator::validate_arg_num_vals: num_vals set...{}", num);
let should_err = if a.is_set(ArgSettings::MultipleOccurrences) {
let should_err = if a.is_multiple_occurrences_set() {
total_num % num != 0
} else {
num != total_num
@ -370,7 +364,7 @@ impl<'help, 'app, 'parser> Validator<'help, 'app, 'parser> {
self.p.app,
a,
num,
if a.is_set(ArgSettings::MultipleOccurrences) {
if a.is_multiple_occurrences_set() {
total_num % num
} else {
total_num
@ -414,7 +408,7 @@ impl<'help, 'app, 'parser> Validator<'help, 'app, 'parser> {
};
// Issue 665 (https://github.com/clap-rs/clap/issues/665)
// Issue 1105 (https://github.com/clap-rs/clap/issues/1105)
if a.is_set(ArgSettings::TakesValue) && !min_vals_zero && ma.all_val_groups_empty() {
if a.is_takes_value_set() && !min_vals_zero && ma.all_val_groups_empty() {
return Err(Error::empty_value(
self.p.app,
&a.possible_vals
@ -549,7 +543,7 @@ impl<'help, 'app, 'parser> Validator<'help, 'app, 'parser> {
.filter(|n| {
// Filter out the args we don't want to specify.
self.p.app.find(n).map_or(true, |a| {
!a.is_set(ArgSettings::Hidden) && !self.p.required.contains(&a.id)
!a.is_hide_set() && !self.p.required.contains(&a.id)
})
})
.cloned()

View file

@ -528,7 +528,7 @@ fn delim_values_only_pos_follows_with_delim() {
let r = App::new("onlypos")
.args(&[
arg!(f: -f [flag] "some opt"),
arg!([arg] ... "some arg").use_delimiter(true),
arg!([arg] ... "some arg").use_value_delimiter(true),
])
.try_get_matches_from(vec!["", "--", "-f", "-g,x"]);
assert!(r.is_ok(), "{}", r.unwrap_err());
@ -545,7 +545,7 @@ fn delim_values_only_pos_follows_with_delim() {
fn delim_values_trailingvararg_with_delim() {
let m = App::new("positional")
.setting(AppSettings::TrailingVarArg)
.arg(arg!([opt] ... "some pos").use_delimiter(true))
.arg(arg!([opt] ... "some pos").use_value_delimiter(true))
.try_get_matches_from(vec!["", "test", "--foo", "-Wl,-bar"])
.unwrap();
assert!(m.is_present("opt"));
@ -1066,7 +1066,7 @@ fn aaos_opts_mult() {
arg!(--opt <val> ... "some option")
.number_of_values(1)
.takes_value(true)
.use_delimiter(true)
.use_value_delimiter(true)
.require_delimiter(true),
)
.try_get_matches_from(vec!["", "--opt=some", "--opt=other", "--opt=one,two"]);
@ -1127,7 +1127,7 @@ fn aaos_pos_mult() {
fn aaos_option_use_delim_false() {
let m = App::new("posix")
.setting(AppSettings::AllArgsOverrideSelf)
.arg(arg!(--opt <val> "some option").use_delimiter(false))
.arg(arg!(--opt <val> "some option").use_value_delimiter(false))
.try_get_matches_from(vec!["", "--opt=some,other", "--opt=one,two"])
.unwrap();
assert!(m.is_present("opt"));

View file

@ -97,7 +97,7 @@ fn opt_eq_mult_def_delim() {
.long("opt")
.takes_value(true)
.multiple_values(true)
.use_delimiter(true),
.use_value_delimiter(true),
)
.try_get_matches_from(vec!["", "--opt=val1,val2,val3"]);

View file

@ -191,7 +191,7 @@ fn multiple_one() {
arg!([arg] "some opt")
.env("CLP_TEST_ENV_MO")
.takes_value(true)
.use_delimiter(true)
.use_value_delimiter(true)
.multiple_values(true),
)
.try_get_matches_from(vec![""]);
@ -212,7 +212,7 @@ fn multiple_three() {
arg!([arg] "some opt")
.env("CLP_TEST_ENV_MULTI1")
.takes_value(true)
.use_delimiter(true)
.use_value_delimiter(true)
.multiple_values(true),
)
.try_get_matches_from(vec![""]);

View file

@ -68,7 +68,7 @@ fn grouped_value_long_flag_delimiter() {
Arg::new("option")
.long("option")
.takes_value(true)
.use_delimiter(true)
.use_value_delimiter(true)
.multiple_values(true)
.multiple_occurrences(true),
)
@ -98,7 +98,7 @@ fn grouped_value_short_flag_delimiter() {
Arg::new("option")
.short('o')
.takes_value(true)
.use_delimiter(true)
.use_value_delimiter(true)
.multiple_values(true)
.multiple_occurrences(true),
)

View file

@ -1757,8 +1757,8 @@ fn issue_1052_require_delim_help() {
.required(true)
.value_names(&["some", "val"])
.takes_value(true)
.use_delimiter(true)
.require_delimiter(true)
.use_value_delimiter(true)
.require_value_delimiter(true)
.value_delimiter(':'),
);
@ -1781,8 +1781,8 @@ fn custom_headers_headers() {
.required(true)
.value_names(&["some", "val"])
.takes_value(true)
.use_delimiter(true)
.require_delimiter(true)
.use_value_delimiter(true)
.require_value_delimiter(true)
.value_delimiter(':'),
)
.next_help_heading(Some("NETWORKING"))
@ -1838,8 +1838,8 @@ fn multiple_custom_help_headers() {
.required(true)
.value_names(&["some", "val"])
.takes_value(true)
.use_delimiter(true)
.require_delimiter(true)
.use_value_delimiter(true)
.require_value_delimiter(true)
.value_delimiter(':'),
)
.next_help_heading(Some("NETWORKING"))

View file

@ -159,7 +159,7 @@ fn indices_mult_opt_value_delim_eq() {
Arg::new("option")
.short('o')
.takes_value(true)
.use_delimiter(true)
.use_value_delimiter(true)
.multiple_values(true),
)
.try_get_matches_from(vec!["myapp", "-o=val1,val2,val3"])

View file

@ -503,7 +503,7 @@ fn sep_long_equals() {
Arg::new("option")
.long("option")
.help("multiple options")
.use_delimiter(true),
.use_value_delimiter(true),
)
.try_get_matches_from(vec!["", "--option=val1,val2,val3"]);
@ -525,7 +525,7 @@ fn sep_long_space() {
Arg::new("option")
.long("option")
.help("multiple options")
.use_delimiter(true),
.use_value_delimiter(true),
)
.try_get_matches_from(vec!["", "--option", "val1,val2,val3"]);
@ -547,7 +547,7 @@ fn sep_short_equals() {
Arg::new("option")
.short('o')
.help("multiple options")
.use_delimiter(true),
.use_value_delimiter(true),
)
.try_get_matches_from(vec!["", "-o=val1,val2,val3"]);
@ -569,7 +569,7 @@ fn sep_short_space() {
Arg::new("option")
.short('o')
.help("multiple options")
.use_delimiter(true),
.use_value_delimiter(true),
)
.try_get_matches_from(vec!["", "-o", "val1,val2,val3"]);
@ -591,7 +591,7 @@ fn sep_short_no_space() {
Arg::new("option")
.short('o')
.help("multiple options")
.use_delimiter(true),
.use_value_delimiter(true),
)
.try_get_matches_from(vec!["", "-oval1,val2,val3"]);
@ -612,7 +612,7 @@ fn sep_positional() {
.arg(
Arg::new("option")
.help("multiple options")
.use_delimiter(true),
.use_value_delimiter(true),
)
.try_get_matches_from(vec!["", "val1,val2,val3"]);
@ -678,7 +678,7 @@ fn no_sep() {
.long("option")
.help("multiple options")
.takes_value(true)
.use_delimiter(false),
.use_value_delimiter(false),
)
.try_get_matches_from(vec!["", "--option=val1,val2,val3"]);
@ -697,7 +697,7 @@ fn no_sep_positional() {
Arg::new("option")
.help("multiple options")
.takes_value(true)
.use_delimiter(false),
.use_value_delimiter(false),
)
.try_get_matches_from(vec!["", "val1,val2,val3"]);
@ -716,8 +716,8 @@ fn req_delimiter_long() {
Arg::new("option")
.long("option")
.multiple_values(true)
.use_delimiter(true)
.require_delimiter(true),
.use_value_delimiter(true)
.require_value_delimiter(true),
)
.arg(
Arg::new("args")
@ -749,8 +749,8 @@ fn req_delimiter_long_with_equal() {
Arg::new("option")
.long("option")
.multiple_values(true)
.use_delimiter(true)
.require_delimiter(true),
.use_value_delimiter(true)
.require_value_delimiter(true),
)
.arg(
Arg::new("args")
@ -782,8 +782,8 @@ fn req_delimiter_short_with_space() {
Arg::new("option")
.short('o')
.multiple_values(true)
.use_delimiter(true)
.require_delimiter(true),
.use_value_delimiter(true)
.require_value_delimiter(true),
)
.arg(
Arg::new("args")
@ -815,8 +815,8 @@ fn req_delimiter_short_with_no_space() {
Arg::new("option")
.short('o')
.multiple_values(true)
.use_delimiter(true)
.require_delimiter(true),
.use_value_delimiter(true)
.require_value_delimiter(true),
)
.arg(
Arg::new("args")
@ -848,8 +848,8 @@ fn req_delimiter_short_with_equal() {
Arg::new("option")
.short('o')
.multiple_values(true)
.use_delimiter(true)
.require_delimiter(true),
.use_value_delimiter(true)
.require_value_delimiter(true),
)
.arg(
Arg::new("args")
@ -883,8 +883,8 @@ fn req_delimiter_complex() {
.short('o')
.multiple_values(true)
.multiple_occurrences(true)
.use_delimiter(true)
.require_delimiter(true),
.use_value_delimiter(true)
.require_value_delimiter(true),
)
.arg(
Arg::new("args")

View file

@ -305,7 +305,7 @@ fn multiple_vals_pos_arg_delim() {
.arg(
arg!(o: -o <opt> "some opt")
.multiple_values(true)
.use_delimiter(true),
.use_value_delimiter(true),
)
.arg(arg!([file] "some file"))
.try_get_matches_from(vec!["", "-o", "1,2", "some"]);
@ -322,8 +322,8 @@ fn require_delims_no_delim() {
let r = App::new("mvae")
.arg(
arg!(o: -o [opt] ... "some opt")
.use_delimiter(true)
.require_delimiter(true),
.use_value_delimiter(true)
.require_value_delimiter(true),
)
.arg(arg!([file] "some file"))
.try_get_matches_from(vec!["mvae", "-o", "1", "2", "some"]);
@ -338,8 +338,8 @@ fn require_delims() {
.arg(
arg!(o: -o <opt> "some opt")
.multiple_values(true)
.use_delimiter(true)
.require_delimiter(true),
.use_value_delimiter(true)
.require_value_delimiter(true),
)
.arg(arg!([file] "some file"))
.try_get_matches_from(vec!["", "-o", "1,2", "some"]);

View file

@ -51,8 +51,8 @@ fn mult_option_require_delim_overrides_itself() {
.overrides_with("opt")
.number_of_values(1)
.takes_value(true)
.use_delimiter(true)
.require_delimiter(true),
.use_value_delimiter(true)
.require_value_delimiter(true),
)
.try_get_matches_from(vec!["", "--opt=some", "--opt=other", "--opt=one,two"]);
assert!(res.is_ok(), "{}", res.unwrap_err());

View file

@ -296,7 +296,7 @@ mod arg {
assert_eq!(arg.get_name(), "foo");
assert_eq!(arg.get_long(), Some("bar"));
assert_eq!(arg.get_value_names(), Some(vec!["NUM"].as_slice()));
assert!(arg.is_set(clap::ArgSettings::Required));
assert!(arg.is_required_set());
}
#[test]
@ -305,7 +305,7 @@ mod arg {
assert_eq!(arg.get_name(), "bar");
assert_eq!(arg.get_long(), Some("bar"));
assert_eq!(arg.get_value_names(), Some(vec!["NUM"].as_slice()));
assert!(arg.is_set(clap::ArgSettings::Required));
assert!(arg.is_required_set());
}
#[test]
@ -314,7 +314,7 @@ mod arg {
assert_eq!(arg.get_name(), "NUM");
assert_eq!(arg.get_long(), None);
assert_eq!(arg.get_value_names(), Some(vec!["NUM"].as_slice()));
assert!(arg.is_set(clap::ArgSettings::Required));
assert!(arg.is_required_set());
}
#[test]
@ -334,29 +334,29 @@ mod arg {
let arg = clap::arg!(foo: -b);
assert_eq!(arg.get_name(), "foo");
assert_eq!(arg.get_short(), Some('b'));
assert!(!arg.is_set(clap::ArgSettings::MultipleOccurrences));
assert!(!arg.is_set(clap::ArgSettings::Required));
assert!(!arg.is_multiple_occurrences_set());
assert!(!arg.is_required_set());
assert_eq!(arg.get_help(), None);
let arg = clap::arg!(foo: -'b');
assert_eq!(arg.get_name(), "foo");
assert_eq!(arg.get_short(), Some('b'));
assert!(!arg.is_set(clap::ArgSettings::MultipleOccurrences));
assert!(!arg.is_set(clap::ArgSettings::Required));
assert!(!arg.is_multiple_occurrences_set());
assert!(!arg.is_required_set());
assert_eq!(arg.get_help(), None);
let arg = clap::arg!(foo: -b ...);
assert_eq!(arg.get_name(), "foo");
assert_eq!(arg.get_short(), Some('b'));
assert!(arg.is_set(clap::ArgSettings::MultipleOccurrences));
assert!(!arg.is_set(clap::ArgSettings::Required));
assert!(arg.is_multiple_occurrences_set());
assert!(!arg.is_required_set());
assert_eq!(arg.get_help(), None);
let arg = clap::arg!(foo: -b "How to use it");
assert_eq!(arg.get_name(), "foo");
assert_eq!(arg.get_short(), Some('b'));
assert!(!arg.is_set(clap::ArgSettings::MultipleOccurrences));
assert!(!arg.is_set(clap::ArgSettings::Required));
assert!(!arg.is_multiple_occurrences_set());
assert!(!arg.is_required_set());
assert_eq!(arg.get_help(), Some("How to use it"));
}
@ -366,32 +366,32 @@ mod arg {
assert_eq!(arg.get_name(), "foo");
assert_eq!(arg.get_long(), Some("hello"));
assert_eq!(arg.get_short(), Some('b'));
assert!(!arg.is_set(clap::ArgSettings::MultipleOccurrences));
assert!(!arg.is_set(clap::ArgSettings::Required));
assert!(!arg.is_multiple_occurrences_set());
assert!(!arg.is_required_set());
assert_eq!(arg.get_help(), None);
let arg = clap::arg!(foo: -'b' --hello);
assert_eq!(arg.get_name(), "foo");
assert_eq!(arg.get_long(), Some("hello"));
assert_eq!(arg.get_short(), Some('b'));
assert!(!arg.is_set(clap::ArgSettings::MultipleOccurrences));
assert!(!arg.is_set(clap::ArgSettings::Required));
assert!(!arg.is_multiple_occurrences_set());
assert!(!arg.is_required_set());
assert_eq!(arg.get_help(), None);
let arg = clap::arg!(foo: -b --hello ...);
assert_eq!(arg.get_name(), "foo");
assert_eq!(arg.get_long(), Some("hello"));
assert_eq!(arg.get_short(), Some('b'));
assert!(arg.is_set(clap::ArgSettings::MultipleOccurrences));
assert!(!arg.is_set(clap::ArgSettings::Required));
assert!(arg.is_multiple_occurrences_set());
assert!(!arg.is_required_set());
assert_eq!(arg.get_help(), None);
let arg = clap::arg!(foo: -b --hello "How to use it");
assert_eq!(arg.get_name(), "foo");
assert_eq!(arg.get_long(), Some("hello"));
assert_eq!(arg.get_short(), Some('b'));
assert!(!arg.is_set(clap::ArgSettings::MultipleOccurrences));
assert!(!arg.is_set(clap::ArgSettings::Required));
assert!(!arg.is_multiple_occurrences_set());
assert!(!arg.is_required_set());
assert_eq!(arg.get_help(), Some("How to use it"));
}
@ -400,43 +400,43 @@ mod arg {
let arg = clap::arg!(<NUM>);
assert_eq!(arg.get_name(), "NUM");
assert_eq!(arg.get_value_names(), Some(vec!["NUM"].as_slice()));
assert!(!arg.is_set(clap::ArgSettings::MultipleOccurrences));
assert!(arg.is_set(clap::ArgSettings::Required));
assert!(!arg.is_multiple_occurrences_set());
assert!(arg.is_required_set());
assert_eq!(arg.get_help(), None);
let arg = clap::arg!([NUM]);
assert_eq!(arg.get_name(), "NUM");
assert_eq!(arg.get_value_names(), Some(vec!["NUM"].as_slice()));
assert!(!arg.is_set(clap::ArgSettings::MultipleOccurrences));
assert!(!arg.is_set(clap::ArgSettings::Required));
assert!(!arg.is_multiple_occurrences_set());
assert!(!arg.is_required_set());
assert_eq!(arg.get_help(), None);
let arg = clap::arg!(<NUM>);
assert_eq!(arg.get_name(), "NUM");
assert_eq!(arg.get_value_names(), Some(vec!["NUM"].as_slice()));
assert!(!arg.is_set(clap::ArgSettings::MultipleOccurrences));
assert!(arg.is_set(clap::ArgSettings::Required));
assert!(!arg.is_multiple_occurrences_set());
assert!(arg.is_required_set());
assert_eq!(arg.get_help(), None);
let arg = clap::arg!(foo: <NUM>);
assert_eq!(arg.get_name(), "foo");
assert_eq!(arg.get_value_names(), Some(vec!["NUM"].as_slice()));
assert!(!arg.is_set(clap::ArgSettings::MultipleOccurrences));
assert!(arg.is_set(clap::ArgSettings::Required));
assert!(!arg.is_multiple_occurrences_set());
assert!(arg.is_required_set());
assert_eq!(arg.get_help(), None);
let arg = clap::arg!(<NUM> ...);
assert_eq!(arg.get_name(), "NUM");
assert_eq!(arg.get_value_names(), Some(vec!["NUM"].as_slice()));
assert!(arg.is_set(clap::ArgSettings::MultipleOccurrences));
assert!(arg.is_set(clap::ArgSettings::Required));
assert!(arg.is_multiple_occurrences_set());
assert!(arg.is_required_set());
assert_eq!(arg.get_help(), None);
let arg = clap::arg!(<NUM> "How to use it");
assert_eq!(arg.get_name(), "NUM");
assert_eq!(arg.get_value_names(), Some(vec!["NUM"].as_slice()));
assert!(!arg.is_set(clap::ArgSettings::MultipleOccurrences));
assert!(arg.is_set(clap::ArgSettings::Required));
assert!(!arg.is_multiple_occurrences_set());
assert!(arg.is_required_set());
assert_eq!(arg.get_help(), Some("How to use it"));
}
}