|
2 | 2 | use crate::builder::IntoResettable; |
3 | 3 | use crate::util::Id; |
4 | 4 |
|
5 | | -/// Family of related [arguments]. |
| 5 | +/// Specifies a logical group of [arguments] |
6 | 6 | /// |
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 |
10 | 11 | /// |
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]. |
31 | 14 | /// |
32 | 15 | /// # Examples |
33 | 16 | /// |
@@ -78,12 +61,9 @@ use crate::util::Id; |
78 | 61 | /// ); |
79 | 62 | /// // we could also alternatively check each arg individually (not shown here) |
80 | 63 | /// ``` |
81 | | -/// [`ArgGroup::multiple(true)`]: ArgGroup::multiple() |
82 | | -/// |
83 | | -/// [`ArgGroup::multiple(false)`]: ArgGroup::multiple() |
84 | 64 | /// [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() |
87 | 67 | #[derive(Default, Clone, Debug, PartialEq, Eq)] |
88 | 68 | pub struct ArgGroup { |
89 | 69 | pub(crate) id: Id, |
|
0 commit comments