Skip to content
This repository has been archived by the owner on Jan 1, 2022. It is now read-only.

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

Open
2 tasks done
epage opened this issue Dec 6, 2021 · 2 comments
Open
2 tasks done

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

epage opened this issue Dec 6, 2021 · 2 comments

Comments

@epage
Copy link
Owner

epage commented Dec 6, 2021

Issue by MrrRaph
Thursday Aug 26, 2021 at 12:49 GMT
Originally opened as clap-rs/clap#2739


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_
@epage
Copy link
Owner Author

epage commented Dec 6, 2021

Comment by epage
Thursday Aug 26, 2021 at 13:40 GMT


To help understand the use case, how are the flags different if they have the same help message? Or is the flag name meant to be context enough to clarify, like a command dealing with semver versions have --major, --minor, --patch` flags?

@epage
Copy link
Owner Author

epage commented Dec 6, 2021

Comment by MrrRaph
Thursday Aug 26, 2021 at 13:42 GMT


I mean by the same/unique help message including "or ..." in it like:

... : "Major or Minor or Patch.."

I'm building an app with Clap and I'm facing with this kind of "help duplicates" that could be nicer if more compact:

HOST DISCOVERY:
        --sL                                 List Scan - simply list targets to scan
        --sn                                 Ping Scan - disable port scan
        --Pn                                 Treat all hosts as online -- skip host discovery
        --PS <portlist>                      TCP SYN discovery to given ports
        --PA <portlist>                      TCP ACK discovery to given ports
        --PU <portlist>                      UDP discovery to given ports
        --PY <portlist>                      SCTP discovery to given ports

What It Should Be:

HOST DISCOVERY:
        --sL                                 List Scan - simply list targets to scan
        --sn                                 Ping Scan - disable port scan
        --Pn                                 Treat all hosts as online -- skip host discovery
        --PS/PA/PU/PY <portlist>             TCP SYN/ACK, UDP and SCTP discovery to given ports

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant