Repository: clap-rs/clap (rust)

Issue:
FR: Prefix argument long and short aliases in help output with -- and -
### 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

### Clap Version

master

### Describe your use case

Currently, the help output shows aliases without leading `--` and `-`:

```
Options:
  -o, --opt <opt>  [short aliases: v]
  -f, --flag       [aliases: flag1] [short aliases: a, b, 🦆]
```

This makes the aliases appear like (sub)commands and hinder copy-pasting into the command line directly.

### Describe the solution you'd like

If the leading `--` and `-` are included, then the aliases will be formatted consistently with the arguments at the start of each line. It will also be easier to copy and paste the aliases correctly elsewhere:

```
Options:
  -o, --opt <opt>  [short aliases: -v]
  -f, --flag       [aliases: --flag1] [short aliases: -a, -b, -🦆]
```

### Alternatives, if applicable

Sticking with the status quo and relying on the user correctly prefixing long aliases with `--` and short aliases with `-` after identifying the aliases from the help output.

### Additional Context

_No response_

Pull request description:
feat(help): Prefix argument long and short aliases in output with `--` and `-`
Fixes #5997.

Patch:
diff --git a/clap_builder/src/output/help_template.rs b/clap_builder/src/output/help_template.rs
index 98d9aad9..801fcbfa 100644
--- a/clap_builder/src/output/help_template.rs
+++ b/clap_builder/src/output/help_template.rs
@@ -789,7 +789,7 @@ impl HelpTemplate<'_, '_> {
             .aliases
             .iter()
             .filter(|&als| als.1) // visible
-            .map(|als| als.0.as_str()) // name
+            .map(|als| format!("--{}", als.0)) // name
             .collect::<Vec<_>>()
             .join(", ");
         if !als.is_empty() {
@@ -801,7 +801,7 @@ impl HelpTemplate<'_, '_> {
             .short_aliases
             .iter()
             .filter(|&als| als.1) // visible
-            .map(|&als| als.0.to_string()) // name
+            .map(|&als| format!("-{}", als.0)) // name
             .collect::<Vec<_>>()
             .join(", ");
         if !als.is_empty() {


Test patch:
diff --git a/tests/builder/arg_aliases.rs b/tests/builder/arg_aliases.rs
index b602964a..0d925ce8 100644
--- a/tests/builder/arg_aliases.rs
+++ b/tests/builder/arg_aliases.rs
@@ -226,8 +226,8 @@ Some help
 Usage: ct test [OPTIONS]
 
 Options:
-  -o, --opt <opt>  [aliases: visible]
-  -f, --flag       [aliases: v_flg, flag2, flg3]
+  -o, --opt <opt>  [aliases: --visible]
+  -f, --flag       [aliases: --v_flg, --flag2, --flg3]
   -h, --help       Print help
   -V, --version    Print version
 ";
diff --git a/tests/builder/arg_aliases_short.rs b/tests/builder/arg_aliases_short.rs
index 3a577b94..60a84305 100644
--- a/tests/builder/arg_aliases_short.rs
+++ b/tests/builder/arg_aliases_short.rs
@@ -193,8 +193,8 @@ Some help
 Usage: ct test [OPTIONS]
 
 Options:
-  -o, --opt <opt>  [short aliases: v]
-  -f, --flag       [aliases: flag1] [short aliases: a, b, 🦆]
+  -o, --opt <opt>  [short aliases: -v]
+  -f, --flag       [aliases: --flag1] [short aliases: -a, -b, -🦆]
   -h, --help       Print help
   -V, --version    Print version
 ";