Repository: clap-rs/clap (language: rust)

Issue:
arg!: parsing problem of whether Arg or Value is required
### Please complete the following tasks

- [X] I have searched the [discussions](https://github.com/clap-rs/clap/discussions)
- [X] I have searched the [open](https://github.com/clap-rs/clap/issues) and [rejected](https://github.com/clap-rs/clap/issues?q=is%3Aissue+label%3AS-wont-fix+is%3Aclosed) issues

### Rust Version

rustc 1.60.0

### Clap Version

3.1.9

### Minimal reproducible code

```rust
fn main() {
    let command = Command::new("test")
        .arg(arg!(--foo [FOO]))
        .arg(arg!(--bar <BAR>))
        .group(ArgGroup::new("group").args(&["foo", "bar"]).required(true));
    // assert!(command.try_get_matches_from(["", "--bar", "value"]).is_ok());
    assert!(command.try_get_matches_from(["", "--foo", "value"]).is_ok());
}
```


### Steps to reproduce the bug with the above code

cargo run

### Actual Behaviour

"test --bar value" succeeded.
"test --foo value" failed.(Errorkind: MissingRequiredArgument) Because \<BAR\> will set --bar as REQUIRED.

### Expected Behaviour

test <--foo [\<FOO\>...]|--bar \<BAR\>>

Group args should be mutually exclusive. 
The setting for REQUIRED in arg! marco should be more explicit.

### Additional Context

Question: #3641

### Debug Output

_No response_


Discussion / hints:

Fix patch:
diff --git a/src/parse/parser.rs b/src/parse/parser.rs
index ee981ca07c3..030a5b918f0 100644
--- a/src/parse/parser.rs
+++ b/src/parse/parser.rs
@@ -22,7 +22,7 @@ use crate::util::Id;
 use crate::{INTERNAL_ERROR_MSG, INVALID_UTF8};
 
 pub(crate) struct Parser<'help, 'cmd> {
-    pub(crate) cmd: &'cmd mut Command<'help>,
+    cmd: &'cmd mut Command<'help>,
     seen: Vec<Id>,
     cur_idx: Cell<usize>,
     /// Index of the previous flag subcommand in a group of flags.


Test patch:
diff --git a/tests/builder/groups.rs b/tests/builder/groups.rs
index a4faef422a7..76d5761a51d 100644
--- a/tests/builder/groups.rs
+++ b/tests/builder/groups.rs
@@ -257,6 +257,19 @@ fn group_multiple_args_error() {
     assert_eq!(err.kind(), ErrorKind::ArgumentConflict);
 }
 
+#[test]
+fn group_overrides_required() {
+    let command = Command::new("group")
+        .arg(arg!(--foo <FOO>))
+        .arg(arg!(--bar <BAR>))
+        .group(ArgGroup::new("group").args(&["foo", "bar"]).required(true));
+    let result = command.try_get_matches_from(vec!["group", "--foo", "value"]);
+    assert!(result.is_ok(), "{}", result.unwrap_err());
+    let m = result.unwrap();
+    assert!(m.is_present("foo"));
+    assert!(!m.is_present("bar"));
+}
+
 #[test]
 fn group_usage_use_val_name() {
     static GROUP_USAGE_USE_VAL_NAME: &str = "prog