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

Issue:
Use of ArgAction::Set instead of ArgAction::SetTrue gives confusing runtime error
### 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.70.0-nightly (7b4f48927 2023-03-12)

### Clap Version

4.1.8

### Minimal reproducible code

```rust
use clap::*;

fn main() {
     let args = Command::new("test")
        .arg(Arg::new("overwrite")
            .short('f')
            .long("overwrite")
            .action(ArgAction::Set))
        .get_matches();
        
    let overwrite = args.get_flag("overwrite");
}
```


### Steps to reproduce the bug with the above code

cargo run


### Actual Behaviour

thread 'main' panicked at 'ArgAction::SetTrue / ArgAction::SetFalse is defaulted'

### Expected Behaviour

The message could be more direct, i.e. point out the root cause that `ArgAction::Set` is not the same as `ArgAction::SetTrue`. I don't know what "being defaulted" is supposed to mean in this context, and it doesn't help resolve the problem.



### Additional Context

_No response_

### Debug Output

_No response_


Discussion / hints:

Fix patch:
diff --git a/src/parser/matches/arg_matches.rs b/src/parser/matches/arg_matches.rs
index 13ceea33f17..67d2918d0bd 100644
--- a/src/parser/matches/arg_matches.rs
+++ b/src/parser/matches/arg_matches.rs
@@ -139,9 +139,12 @@ impl ArgMatches {
     /// ```
     #[cfg_attr(debug_assertions, track_caller)]
     pub fn get_count(&self, id: &str) -> u8 {
-        *self
-            .get_one::<u8>(id)
-            .expect("ArgAction::Count is defaulted")
+        *self.get_one::<u8>(id).unwrap_or_else(|| {
+            panic!(
+                "arg `{}`'s `ArgAction` should be `Count` which should provide a default",
+                id
+            )
+        })
     }
 
     /// Gets the value of a specific [`ArgAction::SetTrue`][crate::ArgAction::SetTrue] or [`ArgAction::SetFalse`][crate::ArgAction::SetFalse] flag
@@ -173,7 +176,12 @@ impl ArgMatches {
     pub fn get_flag(&self, id: &str) -> bool {
         *self
             .get_one::<bool>(id)
-            .expect("ArgAction::SetTrue / ArgAction::SetFalse is defaulted")
+            .unwrap_or_else(|| {
+                panic!(
+                    "arg `{}`'s `ArgAction` should be one of `SetTrue`, `SetFalse` which should provide a default",
+                    id
+                )
+            })
     }
 
     /// Iterate over values of a specific option or positional argument.


Test patch: