Skip to content

Commit 3c82418

Browse files
authored
Merge pull request clap-rs#4072 from epage/group
fix(parser)!: Store args in a group, rather than values
2 parents a549457 + 41be1be commit 3c82418

File tree

30 files changed

+603
-600
lines changed

30 files changed

+603
-600
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
4040
built-in flags and be copied to all subcommands, instead disable
4141
the built-in flags (`Command::disable_help_flag`,
4242
`Command::disable_version_flag`) and mark the custom flags as `global(true)`.
43+
- Looking up a group in `ArgMatches` now returns the arg `Id`s, rather than the values.
44+
- Various `Arg`, `Command`, and `ArgGroup` calls were switched from accepting `&[]` to `[]` via `IntoIterator`
4345
- *(help)* Make `DeriveDisplayOrder` the default and removed the setting. To sort help, set `next_display_order(None)` (#2808)
4446
- *(help)* Subcommand display order respects `Command::next_display_order` instead of `DeriveDisplayOrder` and using its own initial display order value (#2808)
4547
- *(env)* Parse `--help` and `--version` like any `ArgAction::SetTrue` flag (#3776)

clap_bench/benches/05_ripgrep.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ where
316316
.arg(flag("help"))
317317
.arg(flag("version").short('V'))
318318
// First, set up primary positional/flag arguments.
319-
.arg(arg("pattern").required_unless_present_any(&[
319+
.arg(arg("pattern").required_unless_present_any([
320320
"file",
321321
"files",
322322
"help-short",
@@ -337,9 +337,9 @@ where
337337
flag("files")
338338
// This should also conflict with `pattern`, but the first file
339339
// path will actually be in `pattern`.
340-
.conflicts_with_all(&["file", "regexp", "type-list"]),
340+
.conflicts_with_all(["file", "regexp", "type-list"]),
341341
)
342-
.arg(flag("type-list").conflicts_with_all(&["file", "files", "pattern", "regexp"]))
342+
.arg(flag("type-list").conflicts_with_all(["file", "files", "pattern", "regexp"]))
343343
// Second, set up common flags.
344344
.arg(flag("text").short('a'))
345345
.arg(flag("count").short('c'))

clap_bench/benches/06_rustup.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ fn build_cli() -> Command<'static> {
263263
.action(ArgAction::SetTrue)
264264
.help("Standard library API documentation"),
265265
)
266-
.group(ArgGroup::new("page").args(&["book", "std"])),
266+
.group(ArgGroup::new("page").args(["book", "std"])),
267267
)
268268
.subcommand(
269269
Command::new("man")

clap_mangen/src/render.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub(crate) fn synopsis(roff: &mut Roff, cmd: &clap::Command) {
6363
if let Some(value) = arg.get_value_names() {
6464
line.push(italic(value.join(" ")));
6565
} else {
66-
line.push(italic(arg.get_id()));
66+
line.push(italic(arg.get_id().as_str()));
6767
}
6868
line.push(roman(rhs));
6969
line.push(roman(" "));
@@ -129,7 +129,7 @@ pub(crate) fn options(roff: &mut Roff, cmd: &clap::Command) {
129129
if let Some(value) = pos.get_value_names() {
130130
header.push(italic(value.join(" ")));
131131
} else {
132-
header.push(italic(pos.get_id()));
132+
header.push(italic(pos.get_id().as_str()));
133133
};
134134
header.push(roman(rhs));
135135

examples/tutorial_builder/04_03_relations.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn main() {
1414
.group(
1515
ArgGroup::new("vers")
1616
.required(true)
17-
.args(&["set-ver", "major", "minor", "patch"]),
17+
.args(["set-ver", "major", "minor", "patch"]),
1818
)
1919
// Arguments can also be added to a group individually, these two arguments
2020
// are part of the "input" group which is not required

examples/tutorial_derive/04_03_relations.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use clap::{ArgGroup, Parser};
55
#[clap(group(
66
ArgGroup::new("vers")
77
.required(true)
8-
.args(&["set_ver", "major", "minor", "patch"]),
8+
.args(["set_ver", "major", "minor", "patch"]),
99
))]
1010
struct Cli {
1111
/// set version manually

0 commit comments

Comments
 (0)