mirror of
https://github.com/clap-rs/clap
synced 2024-12-14 14:52:33 +00:00
docs(Value Delimiters): updates the docs for the Arg::multiple method WRT value delimiters and default settings
This commit is contained in:
parent
f9e692548e
commit
f9d17a060a
1 changed files with 10 additions and 4 deletions
|
@ -1711,7 +1711,7 @@ impl<'a, 'b> Arg<'a, 'b> {
|
||||||
///
|
///
|
||||||
/// **NOTE:** This does *not* implicitly set [`Arg::multiple(true)`]. This is because
|
/// **NOTE:** This does *not* implicitly set [`Arg::multiple(true)`]. This is because
|
||||||
/// `-o val -o val` is multiple occurrences but a single value and `-o val1 val2` is a single
|
/// `-o val -o val` is multiple occurrences but a single value and `-o val1 val2` is a single
|
||||||
/// occurence with multple values. For positional arguments this **does** set
|
/// occurence with multiple values. For positional arguments this **does** set
|
||||||
/// [`Arg::multiple(true)`] because there is no way to determine the difference between multiple
|
/// [`Arg::multiple(true)`] because there is no way to determine the difference between multiple
|
||||||
/// occurences and multiple values.
|
/// occurences and multiple values.
|
||||||
///
|
///
|
||||||
|
@ -1832,8 +1832,12 @@ impl<'a, 'b> Arg<'a, 'b> {
|
||||||
/// and `val3`) or as a single value (`val1,val2,val3`). Defaults to using `,` (comma) as the
|
/// 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)
|
/// value delimiter for all arguments that accept values (options and positional arguments)
|
||||||
///
|
///
|
||||||
/// **NOTE:** The default is `true`. Setting the value to `true` will reset any previous use of
|
/// **NOTE:** The default is `false`. When set to `true` the default [`Arg::value_delimiter`]
|
||||||
/// [`Arg::value_delimiter`] back to the default of `,` (comma).
|
/// is the comma `,`.
|
||||||
|
///
|
||||||
|
/// **NOTE:** When using methods like [`Arg::multiple`] or [`Arg::max_values`] (i.e. methods
|
||||||
|
/// that imply multiple values, this `use_delimiter` setting will automatically be set to
|
||||||
|
/// `true` and use the comma (`,`) by default.
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
|
@ -1844,6 +1848,7 @@ impl<'a, 'b> Arg<'a, 'b> {
|
||||||
/// let delims = App::new("delims")
|
/// let delims = App::new("delims")
|
||||||
/// .arg(Arg::with_name("option")
|
/// .arg(Arg::with_name("option")
|
||||||
/// .long("option")
|
/// .long("option")
|
||||||
|
/// .use_delimiter(true)
|
||||||
/// .takes_value(true))
|
/// .takes_value(true))
|
||||||
/// .get_matches_from(vec![
|
/// .get_matches_from(vec![
|
||||||
/// "delims",
|
/// "delims",
|
||||||
|
@ -1854,7 +1859,8 @@ impl<'a, 'b> Arg<'a, 'b> {
|
||||||
/// assert_eq!(delims.occurrences_of("option"), 1);
|
/// assert_eq!(delims.occurrences_of("option"), 1);
|
||||||
/// assert_eq!(delims.values_of("option").unwrap().collect::<Vec<_>>(), ["val1", "val2", "val3"]);
|
/// assert_eq!(delims.values_of("option").unwrap().collect::<Vec<_>>(), ["val1", "val2", "val3"]);
|
||||||
/// ```
|
/// ```
|
||||||
/// The next example shows the difference when turning delimiters off.
|
/// The next example shows the difference when turning delimiters off. This is the default
|
||||||
|
/// behavior, unless one of the methods/settings which implies multiple values is set.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use clap::{App, Arg};
|
/// # use clap::{App, Arg};
|
||||||
|
|
Loading…
Reference in a new issue