Skip to content

Commit cb49eba

Browse files
authored
Merge pull request #6177 from epage/heading
docs(group): Cross-link ArgGroup to help heading
2 parents 913cbb1 + c32c382 commit cb49eba

File tree

2 files changed

+12
-31
lines changed

2 files changed

+12
-31
lines changed

clap_builder/src/builder/arg.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2410,9 +2410,10 @@ impl Arg {
24102410
self
24112411
}
24122412

2413-
/// Override the [current] help section.
2413+
/// Override the `--help` section this appears in.
24142414
///
2415-
/// [current]: crate::Command::next_help_heading
2415+
/// For more on the default help heading, see
2416+
/// [`Command::next_help_heading`][crate::Command::next_help_heading].
24162417
#[inline]
24172418
#[must_use]
24182419
pub fn help_heading(mut self, heading: impl IntoResettable<Str>) -> Self {

clap_builder/src/builder/arg_group.rs

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,15 @@
22
use crate::builder::IntoResettable;
33
use crate::util::Id;
44

5-
/// Family of related [arguments].
5+
/// Specifies a logical group of [arguments]
66
///
7-
/// By placing arguments in a logical group, you can create easier requirement and
8-
/// exclusion rules instead of having to list each argument individually, or when you want a rule
9-
/// to apply "any but not all" arguments.
7+
/// You can use this for
8+
/// - applying validation to an entire group, like [`ArgGroup::multiple`]
9+
/// - validate relationships between an argument and a group, like [conflicts] or [requirements]
10+
/// - check which argument in a group was specified on the command-line
1011
///
11-
/// For instance, you can make an entire `ArgGroup` required. If [`ArgGroup::multiple(true)`] is
12-
/// set, this means that at least one argument from that group must be present. If
13-
/// [`ArgGroup::multiple(false)`] is set (the default), one and *only* one must be present.
14-
///
15-
/// You can also do things such as name an entire `ArgGroup` as a [conflict] or [requirement] for
16-
/// another argument, meaning any of the arguments that belong to that group will cause a failure
17-
/// if present, or must be present respectively.
18-
///
19-
/// Perhaps the most common use of `ArgGroup`s is to require one and *only* one argument to be
20-
/// present out of a given set. Imagine that you had multiple arguments, and you want one of them
21-
/// to be required, but making all of them required isn't feasible because perhaps they conflict
22-
/// with each other. For example, lets say that you were building an application where one could
23-
/// set a given version number by supplying a string with an option argument, i.e.
24-
/// `--set-ver v1.2.3`, you also wanted to support automatically using a previous version number
25-
/// and simply incrementing one of the three numbers. So you create three flags `--major`,
26-
/// `--minor`, and `--patch`. All of these arguments shouldn't be used at one time but you want to
27-
/// specify that *at least one* of them is used. For this, you can create a group.
28-
///
29-
/// Finally, you may use `ArgGroup`s to pull a value from a group of arguments when you don't care
30-
/// exactly which argument was actually used at runtime.
12+
/// For visually grouping arguments in help, see instead
13+
/// [`Arg::help_heading`][crate::Arg::help_heading].
3114
///
3215
/// # Examples
3316
///
@@ -78,12 +61,9 @@ use crate::util::Id;
7861
/// );
7962
/// // we could also alternatively check each arg individually (not shown here)
8063
/// ```
81-
/// [`ArgGroup::multiple(true)`]: ArgGroup::multiple()
82-
///
83-
/// [`ArgGroup::multiple(false)`]: ArgGroup::multiple()
8464
/// [arguments]: crate::Arg
85-
/// [conflict]: crate::Arg::conflicts_with()
86-
/// [requirement]: crate::Arg::requires()
65+
/// [conflicts]: crate::Arg::conflicts_with()
66+
/// [requirements]: crate::Arg::requires()
8767
#[derive(Default, Clone, Debug, PartialEq, Eq)]
8868
pub struct ArgGroup {
8969
pub(crate) id: Id,

0 commit comments

Comments
 (0)