Repository: clap-rs/clap (rust)

Issue:
Generated man pages claim that flag options take values
### 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.64.0 (Fedora 1.64.0-1.fc36)

### Clap Version

4.0.17, clap_mangen 0.2.3

### Minimal reproducible code

```rust
use clap::{CommandFactory, Parser};

#[derive(Parser)]
/// Command to do things
pub struct Cmd {
    /// Do thing
    #[clap(long)]
    thing: bool,
}

fn main() {
    Cmd::parse();
    clap_mangen::Man::new(Cmd::command())
        .render(&mut std::io::stdout())
        .unwrap();
}
```

Cargo.toml:

```toml
[package]
name = "clap-man"
version = "0.0.0"
edition = "2021"

[dependencies]
clap = { version = "4", features = ["derive"] }
clap_mangen = "0.2"
```

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

```
cargo run | man -l -
```

### Actual Behaviour

The option description for `--thing` claims that it takes an argument and that that argument defaults to false:

```
clap-man(1)                 General Commands Manual                clap-man(1)

NAME
       clap-man - Command to do things

SYNOPSIS
       clap-man [--thing] [-h|--help]

DESCRIPTION
       Command to do things

OPTIONS
       --thing=THING [default: false]
              Do thing

       -h, --help
              Print help information

                                   clap-man                        clap-man(1)
```

Of course, it doesn't:

```console
$ cargo run -- --thing=true
    Finished dev [unoptimized + debuginfo] target(s) in 0.04s
     Running `target/debug/clap-man --thing=true`
error: The value 'true' was provided to '--thing' but it wasn't expecting any more values

Usage: clap-man --thing

For more information try '--help'
```

### Expected Behaviour

The man page lists the option without any argument, as it did in clap 3.2 / clap_mangen 0.1:

```
clap-man(1)                 General Commands Manual                clap-man(1)

NAME
       clap-man - Command to do things

SYNOPSIS
       clap-man [--thing] [-h|--help]

DESCRIPTION
       Command to do things

OPTIONS
       --thing
              Do thing

       -h, --help
              Print help information

                                   clap-man                        clap-man(1)
```

### Additional Context

_No response_

### Debug Output

_No response_

Pull request:
fix(man): Don't show default values for flags, show ellipsis for repeatable arguments
Fixes #4410.

The help generator for the main clap package uses the `Arg::is_takes_value_set()` method to determine whether it should show a default argument. (See `Arg::stylize_arg_suffix`, on line 4148 of `arg.rs`.) 

I ported the same logic over to clap_mangen, so boolean flag arguments no longer show `[default=false]` (or `[default=0]` for repeatable options), which is not valid.

I also noticed that the generated synopsis does not add a `...` ellipsis for repeatable flags, so I added that as well.

Finally, I updated the snapshot tests to reflect the above changes.

## Example

For the following program (this is essentially `clap_mangen/examples/man.rs`):

```rs

fn main() -> Result<(), std::io::Error> {
    let cmd = Command::new("myapp")
        .version("1.0")
        .author("Kevin K. <kbknapp@gmail.com>:Ola Nordmann <old@nordmann.no>")
        .about("Does awesome things")
        .long_about(
            "With a longer description to help clarify some things.

And a few newlines.",
        )
        .after_help("This is an extra section added to the end of the manpage.")
        .after_long_help("With even more text added.")
        .arg(
            arg!(-c --config <FILE> "Sets a custom config file")
                .long_help("Some more text about how to set a custom config file")
                .default_value("config.toml")
                .env("CONFIG_FILE"),
        )
        .arg(arg!([output] "Sets an output file").default_value("result.txt"))
        .arg(
            arg!(-d --debug ... "Turn debugging information on")
                .env("DEBUG_ON")
                .hide_env(true),
        )
        .subcommand(
            Command::new("test")
                .about("does testing things")
                .arg(arg!(-l --list "Lists test values")),
        );

    Man::new(cmd).render(&mut io::stdout())
}
```
you previously got

```
myapp(1)                                                                             General Commands Manual                                                                            myapp(1)

NAME
       myapp - Does awesome things

SYNOPSIS
       myapp [-c|--config] [--thing] [-d|--debug] [-h|--help] [-V|--version] [output] [subcommands]

DESCRIPTION
       With a longer description to help clarify some things.

       And a few newlines.

OPTIONS
       -c, --config=FILE [default: config.toml]
              Some more text about how to set a custom config file
              May also be specified with the CONFIG_FILE environment variable.

       --thing [default: false]
              Does a thing with a flag

       -d, --debug [default: 0]
              Turn debugging information on

       -h, --help
              Print help information (use `-h` for a summary)

       -V, --version
              Print version information

       [output] [default: result.txt]
              Sets an output file

SUBCOMMANDS
       myapp-test(1)
              does testing things

       myapp-help(1)
              Print this message or the help of the given subcommand(s)

EXTRA
       With even more text added.

VERSION
       v1.0

AUTHORS
       Kevin K. <kbknapp@gmail.com>:Ola Nordmann <old@nordmann.no>

                                                                                            myapp 1.0                                                                                   myapp(1)
```

and now get

```
myapp(1)                                                                             General Commands Manual                                                                            myapp(1)

NAME
       myapp - Does awesome things

SYNOPSIS
       myapp [-c|--config] [--thing] [-d|--debug]... [-h|--help] [-V|--version] [output] [subcommands]

DESCRIPTION
       With a longer description to help clarify some things.

       And a few newlines.

OPTIONS
       -c, --config=FILE [default: config.toml]
              Some more text about how to set a custom config file
              May also be specified with the CONFIG_FILE environment variable.

       --thing
              Does a thing with a flag

       -d, --debug
              Turn debugging information on

       -h, --help
              Print help information (use `-h` for a summary)

       -V, --version
              Print version information

       [output] [default: result.txt]
              Sets an output file

SUBCOMMANDS
       myapp-test(1)
              does testing things

       myapp-help(1)
              Print this message or the help of the given subcommand(s)

EXTRA
       With even more text added.

VERSION
       v1.0

AUTHORS
       Kevin K. <kbknapp@gmail.com>:Ola Nordmann <old@nordmann.no>

                                                                                            myapp 1.0                                                                                   myapp(1)
```


Patch:
diff --git a/clap_mangen/src/render.rs b/clap_mangen/src/render.rs
index e4b09f56..08da00e7 100644
--- a/clap_mangen/src/render.rs
+++ b/clap_mangen/src/render.rs
@@ -1,3 +1,4 @@
+use clap::ArgAction;
 use roff::{bold, italic, roman, Inline, Roff};
 
 pub(crate) fn subcommand_heading(cmd: &clap::Command) -> &str {
@@ -39,22 +40,24 @@ pub(crate) fn synopsis(roff: &mut Roff, cmd: &clap::Command) {
                 line.push(roman("|"));
                 line.push(bold(&format!("--{}", long)));
                 line.push(roman(rhs));
-                line.push(roman(" "));
             }
             (Some(short), None) => {
                 line.push(roman(lhs));
                 line.push(bold(&format!("-{} ", short)));
                 line.push(roman(rhs));
-                line.push(roman(" "));
             }
             (None, Some(long)) => {
                 line.push(roman(lhs));
                 line.push(bold(&format!("--{}", long)));
                 line.push(roman(rhs));
-                line.push(roman(" "));
             }
-            (None, None) => (),
+            (None, None) => continue,
         };
+
+        if matches!(opt.get_action(), ArgAction::Count) {
+            line.push(roman("..."))
+        }
+        line.push(roman(" "));
     }
 
     for arg in cmd.get_positionals() {
@@ -306,7 +309,7 @@ fn option_environment(opt: &clap::Arg) -> Option<Vec<Inline>> {
 }
 
 fn option_default_values(opt: &clap::Arg) -> Option<String> {
-    if opt.is_hide_default_value_set() {
+    if opt.is_hide_default_value_set() || !opt.get_action().takes_values() {
         return None;
     } else if !opt.get_default_values().is_empty() {
         let values = opt


Test patch:
diff --git a/clap_mangen/tests/snapshots/aliases.bash.roff b/clap_mangen/tests/snapshots/aliases.bash.roff
index 959dfaa3..4cd893f1 100644
--- a/clap_mangen/tests/snapshots/aliases.bash.roff
+++ b/clap_mangen/tests/snapshots/aliases.bash.roff
@@ -9,7 +9,7 @@ my/-app /- testing bash completions
 testing bash completions
 .SH OPTIONS
 .TP
-/fB/-f/fR, /fB/-/-flag/fR [default: false]
+/fB/-f/fR, /fB/-/-flag/fR
 cmd flag
 .TP
 /fB/-o/fR, /fB/-/-option/fR
diff --git a/clap_mangen/tests/snapshots/basic.bash.roff b/clap_mangen/tests/snapshots/basic.bash.roff
index b0e0f5b1..e502cd97 100644
--- a/clap_mangen/tests/snapshots/basic.bash.roff
+++ b/clap_mangen/tests/snapshots/basic.bash.roff
@@ -8,10 +8,10 @@ my/-app
 .SH DESCRIPTION
 .SH OPTIONS
 .TP
-/fB/-c/fR [default: false]
+/fB/-c/fR
 
 .TP
-/fB/-v/fR [default: false]
+/fB/-v/fR
 
 .TP
 /fB/-h/fR, /fB/-/-help/fR
diff --git a/clap_mangen/tests/snapshots/feature_sample.bash.roff b/clap_mangen/tests/snapshots/feature_sample.bash.roff
index ad89abed..f3cc3bf6 100644
--- a/clap_mangen/tests/snapshots/feature_sample.bash.roff
+++ b/clap_mangen/tests/snapshots/feature_sample.bash.roff
@@ -4,12 +4,12 @@
 .SH NAME
 my/-app /- Tests completions
 .SH SYNOPSIS
-/fBmy/-app/fR [/fB/-c/fR|/fB/-/-config/fR] [/fB/-h/fR|/fB/-/-help/fR] [/fB/-V/fR|/fB/-/-version/fR] [/fIfile/fR] [/fIchoice/fR] [/fIsubcommands/fR]
+/fBmy/-app/fR [/fB/-c/fR|/fB/-/-config/fR]... [/fB/-h/fR|/fB/-/-help/fR] [/fB/-V/fR|/fB/-/-version/fR] [/fIfile/fR] [/fIchoice/fR] [/fIsubcommands/fR]
 .SH DESCRIPTION
 Tests completions
 .SH OPTIONS
 .TP
-/fB/-c/fR, /fB/-/-config/fR [default: 0]
+/fB/-c/fR, /fB/-/-config/fR
 some config file
 .TP
 /fB/-h/fR, /fB/-/-help/fR
diff --git a/clap_mangen/tests/snapshots/quoting.bash.roff b/clap_mangen/tests/snapshots/quoting.bash.roff
index 7ca1e332..60280b42 100644
--- a/clap_mangen/tests/snapshots/quoting.bash.roff
+++ b/clap_mangen/tests/snapshots/quoting.bash.roff
@@ -8,22 +8,22 @@ my/-app
 .SH DESCRIPTION
 .SH OPTIONS
 .TP
-/fB/-/-single/-quotes/fR [default: false]
+/fB/-/-single/-quotes/fR
 Can be /*(Aqalways/*(Aq, /*(Aqauto/*(Aq, or /*(Aqnever/*(Aq
 .TP
-/fB/-/-double/-quotes/fR [default: false]
+/fB/-/-double/-quotes/fR
 Can be "always", "auto", or "never"
 .TP
-/fB/-/-backticks/fR [default: false]
+/fB/-/-backticks/fR
 For more information see `echo test`
 .TP
-/fB/-/-backslash/fR [default: false]
+/fB/-/-backslash/fR
 Avoid /*(Aq//n/*(Aq
 .TP
-/fB/-/-brackets/fR [default: false]
+/fB/-/-brackets/fR
 List packages [filter]
 .TP
-/fB/-/-expansions/fR [default: false]
+/fB/-/-expansions/fR
 Execute the shell command with $SHELL
 .TP
 /fB/-h/fR, /fB/-/-help/fR
diff --git a/clap_mangen/tests/snapshots/special_commands.bash.roff b/clap_mangen/tests/snapshots/special_commands.bash.roff
index 0cf113f8..db7b607a 100644
--- a/clap_mangen/tests/snapshots/special_commands.bash.roff
+++ b/clap_mangen/tests/snapshots/special_commands.bash.roff
@@ -4,12 +4,12 @@
 .SH NAME
 my/-app /- Tests completions
 .SH SYNOPSIS
-/fBmy/-app/fR [/fB/-c/fR|/fB/-/-config/fR] [/fB/-h/fR|/fB/-/-help/fR] [/fB/-V/fR|/fB/-/-version/fR] [/fIfile/fR] [/fIchoice/fR] [/fIsubcommands/fR]
+/fBmy/-app/fR [/fB/-c/fR|/fB/-/-config/fR]... [/fB/-h/fR|/fB/-/-help/fR] [/fB/-V/fR|/fB/-/-version/fR] [/fIfile/fR] [/fIchoice/fR] [/fIsubcommands/fR]
 .SH DESCRIPTION
 Tests completions
 .SH OPTIONS
 .TP
-/fB/-c/fR, /fB/-/-config/fR [default: 0]
+/fB/-c/fR, /fB/-/-config/fR
 some config file
 .TP
 /fB/-h/fR, /fB/-/-help/fR
diff --git a/clap_mangen/tests/snapshots/sub_subcommands.bash.roff b/clap_mangen/tests/snapshots/sub_subcommands.bash.roff
index f2a22e9d..9f034036 100644
--- a/clap_mangen/tests/snapshots/sub_subcommands.bash.roff
+++ b/clap_mangen/tests/snapshots/sub_subcommands.bash.roff
@@ -4,12 +4,12 @@
 .SH NAME
 my/-app /- Tests completions
 .SH SYNOPSIS
-/fBmy/-app/fR [/fB/-c/fR|/fB/-/-config/fR] [/fB/-h/fR|/fB/-/-help/fR] [/fB/-V/fR|/fB/-/-version/fR] [/fIfile/fR] [/fIchoice/fR] [/fIsubcommands/fR]
+/fBmy/-app/fR [/fB/-c/fR|/fB/-/-config/fR]... [/fB/-h/fR|/fB/-/-help/fR] [/fB/-V/fR|/fB/-/-version/fR] [/fIfile/fR] [/fIchoice/fR] [/fIsubcommands/fR]
 .SH DESCRIPTION
 Tests completions
 .SH OPTIONS
 .TP
-/fB/-c/fR, /fB/-/-config/fR [default: 0]
+/fB/-c/fR, /fB/-/-config/fR
 some config file
 .TP
 /fB/-h/fR, /fB/-/-help/fR