Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
2 tasks done
MrrRaph opened this issue Aug 26, 2021 · 4 comments
Open
2 tasks done

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

MrrRaph opened this issue Aug 26, 2021 · 4 comments
Labels
A-help Area: documentation, including docs.rs, readme, examples, etc... C-enhancement Category: Raise on the bar on expectations S-waiting-on-design Status: Waiting on user-facing design to be resolved before implementing

Comments

@MrrRaph
Copy link

MrrRaph commented Aug 26, 2021

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
Member

epage commented Aug 26, 2021

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?

@MrrRaph
Copy link
Author

MrrRaph commented Aug 26, 2021

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

@pksunkara pksunkara added 💸 $10 A-help Area: documentation, including docs.rs, readme, examples, etc... D: medium labels Aug 31, 2021
@epage epage added C-enhancement Category: Raise on the bar on expectations and removed T: new feature labels Dec 8, 2021
@epage
Copy link
Member

epage commented Dec 13, 2021

Some quick thoughts: I'd probably model this after usages to reduce user confusion. The downside is that would look like --PS <portlist> | --PA <portlist> etc which gets fairly verbose.

@epage epage added S-waiting-on-design Status: Waiting on user-facing design to be resolved before implementing and removed P4: nice to have 💸 $10 labels Dec 13, 2021
@epage
Copy link
Member

epage commented Aug 25, 2022

Might not apply in the reporters case but one way of doing this in CLI11 is by having a string parsed at runtime: https://cliutils.github.io/CLI11/book/chapters/flags.html

I don't think thats the way we should go but I wanted to make note of how others solve similar problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-help Area: documentation, including docs.rs, readme, examples, etc... C-enhancement Category: Raise on the bar on expectations S-waiting-on-design Status: Waiting on user-facing design to be resolved before implementing
Projects
None yet
Development

No branches or pull requests

3 participants