Skip to content

Commit

Permalink
docs: Clarify corner caseses with default values
Browse files Browse the repository at this point in the history
This is meant to lower the chance of confusion with cases like clap-rs#2714 and clap-rs#1586.

This is not meant to be exhaustive, looked at the mentioned cases in
that issue and pattern matched on other ones mentioning "is present".
  • Loading branch information
epage committed Oct 18, 2021
1 parent fb1cc27 commit 3ffcffb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/build/arg/mod.rs
Expand Up @@ -1045,6 +1045,8 @@ impl<'help> Arg<'help> {
///
/// **NOTE** [`Arg::exclusive(true)`] allows specifying an argument which conflicts with every other argument.
///
/// **NOTE:** An argument is considered present when there is a [`Arg::default_value`]
///
/// # Examples
///
/// ```rust
Expand Down Expand Up @@ -1095,6 +1097,8 @@ impl<'help> Arg<'help> {
///
/// **NOTE:** [`Arg::exclusive(true)`] allows specifying an argument which conflicts with every other argument.
///
/// **NOTE:** An argument is considered present when there is a [`Arg::default_value`]
///
/// # Examples
///
/// ```rust
Expand Down Expand Up @@ -1328,6 +1332,8 @@ impl<'help> Arg<'help> {
///
/// **NOTE:** [Conflicting] rules and [override] rules take precedence over being required
///
/// **NOTE:** This argument is considered present when there is a [`Arg::default_value`]
///
/// # Examples
///
/// ```rust
Expand Down Expand Up @@ -1389,6 +1395,8 @@ impl<'help> Arg<'help> {
/// if this arg (`self`) is present and its value equals to `val`.
/// If it does, `another_arg` will be marked as required.
///
/// **NOTE:** This argument is considered present when there is a [`Arg::default_value`]
///
/// # Examples
///
/// ```rust
Expand Down Expand Up @@ -1510,6 +1518,8 @@ impl<'help> Arg<'help> {
/// Allows specifying that this argument is [required] only if the specified
/// `arg` is present at runtime and its value equals `val`.
///
/// **NOTE:** This argument is considered present when there is a [`Arg::default_value`]
///
/// # Examples
///
/// ```rust
Expand Down Expand Up @@ -1786,6 +1796,8 @@ impl<'help> Arg<'help> {
/// **NOTE:** [Conflicting] rules and [override] rules take precedence over being required
/// by default.
///
/// **NOTE:** This argument is considered present when there is a [`Arg::default_value`]
///
/// # Examples
///
/// ```rust
Expand Down
10 changes: 10 additions & 0 deletions src/build/arg_group.rs
Expand Up @@ -249,6 +249,8 @@ impl<'help> ArgGroup<'help> {
/// Use of more than one arg is an error." Vice setting `ArgGroup::multiple(true)` which
/// states, '*At least* one arg from this group must be used. Using multiple is OK."
///
/// **NOTE:** An argument is considered present when there is a [`Arg::default_value`]
///
/// # Examples
///
/// ```rust
Expand Down Expand Up @@ -284,6 +286,8 @@ impl<'help> ArgGroup<'help> {
///
/// **NOTE:** The name provided may be an argument, or group name
///
/// **NOTE:** An argument is considered present when there is a [`Arg::default_value`]
///
/// # Examples
///
/// ```rust
Expand Down Expand Up @@ -319,6 +323,8 @@ impl<'help> ArgGroup<'help> {
///
/// **NOTE:** The names provided may be an argument, or group name
///
/// **NOTE:** An argument is considered present when there is a [`Arg::default_value`]
///
/// # Examples
///
/// ```rust
Expand Down Expand Up @@ -357,6 +363,8 @@ impl<'help> ArgGroup<'help> {
///
/// **NOTE:** The name provided may be an argument, or group name
///
/// **NOTE:** An argument is considered present when there is a [`Arg::default_value`]
///
/// # Examples
///
/// ```rust
Expand Down Expand Up @@ -389,6 +397,8 @@ impl<'help> ArgGroup<'help> {
///
/// **NOTE:** The names provided may be an argument, or group name
///
/// **NOTE:** An argument is considered present when there is a [`Arg::default_value`]
///
/// # Examples
///
/// ```rust
Expand Down

0 comments on commit 3ffcffb

Please sign in to comment.