Skip to content

Regroup "similar" flags/options in the help prompt #2739

Open
@PandH4cker

Description

Please complete the following tasks

  • I have searched the discussions
  • I have searched the existing issues

Clap Version

3.0.0-beta.2

Describe your use case

Hi everyone,

I just suggest to add a simple feature about the display of the help prompt to regroup flags/options that seem to us "similar" and to simplify the help prompt in order to reduce its length and be more compact.

The function should regroup args and be visualized:

Like this:

--PS/PA/PU/PY <portlist>: help message

Instead of:

--PS <portlist> : same help message
--PA <portlist> : same help message
--PU <portlist> : same help message
--PY <portlist>  : same help message

Describe the solution you'd like

It could be nice to have a function like this:

impl<'help> App<'help>
pub fn help_regroup<T: Key>(mut self, arg_id: T, args: &[T], help_message: &str) -> Self

And be used like this:

app
     .arg(Arg::new("PA"))
     .arg(Arg::new("PU"))
     .arg(Arg::new("PY"))
     ...
     .help_regroup("PA", &["PU", "PY"], "Unique Help Message")

OUTPUT:

PA/PU/PY <value_name>: unique_help_message

### Alternatives, if applicable

_No response_

### Additional Context

_No response_

Metadata

Assignees

No one assigned

    Labels

    A-helpArea: documentation, including docs.rs, readme, examples, etc...C-enhancementCategory: Raise on the bar on expectationsS-waiting-on-designStatus: Waiting on user-facing design to be resolved before implementing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions