-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Custom argument display groups #805
Comments
Unfortunately it's not supported at this time unless you simply write the help message yourself (copy/paste your example into For completeness sake, you could force it to happen in clap, but it'd be very hacky even though functional. If you want to see, I can give you a demo 😉 Having said all this, it'd be possible for me to add this is feature, and I'd be curious to know if others want this same thing. I personally think it'd be somewhat of a pain to enter, I'd like to hear some thoughts on the matter :) |
Possibly relates to #686 |
Well... it's not, since it what I'm doing right now. I don't really know what kind of API I want, but since I prefer that options should be in a specific order (I forgot to mention this in OP. In example, there are not only groups that matter, but also an order of options inside. Yes, it's visual only and do not change parsing in any way.), so I guess something like: I'll think about how it can be implemented, API-wise. Sounds like keeping an own help file is the easiest way... |
The order of arguments can already be specified manually (using In fact, the hack I hinted at uses those options, along with afew others to trick the generated help message. |
Here's what I meant by the hack to make it work Is this any better than copy/pasting the help? I know it's looks uglier, but it has the benefit of never falling out of date. Granted, there are drawbacks such as the "can't have a default here" portions. Although there are ways around that; such as unless you have a really good reason not to (like porting a well known CLI), it's considered better UX to use flags instead of options for the |
Adding newlines to About |
I think convention is to use Such as Another option is to group like functionality into a single option. For example, all the "removal" flags become:
Then you could set this up to allow We're digressing from the original topic, but that's fine because I enjoy CLI UX 😄 I'm going to play with adding, "display groups" and see how it feels. I'll post back here with an example once I have it working. |
I thought about groping, but it's harder to generate, from GUI for example, and also it's harder to write, because it will be one, very long line. And I'm already have more than 50 options. In current version I can separate each option with the Actual problem with flags, is that most of them are enabled by default. So it will be just a bunch of keys which disables staff, like: PS: I don't mind discussing CLI UX, since there are not mach articles about it. And |
No, if an argument defaults to true, that means the functionality is "on" by default. So the user not passing the flag is consent for that action to take place (default true), but then you have a Here's the comparison for items defaulting to true:
The inverse also applies. Something that defaults to false, doesn't do some particular action. Then supplying
It makes your CLI more concise, and help messages are easier to read as well.
I think it's actually the opposite. And your help message for that flag can say, "By default svgcleaner removes X, this flag disables that removal" Because the other way around, what you'll end up seeing is people running There's other oddities as well, such as users forgetting whether it's I'm not saying it's wrong, as it can totally be done with
I'm actually working on releasing an mdBook (same as Rust book) about CLI UX in general, and using Rust, since it's something I really enjoy working on and thinking about. It'll be a while before it's ready though. |
Thanks. I'll keep thinking about it. Waiting for a book. |
I did some playing with this and ergonomics aren't great. It's also a huge rework of how clap writes a help message and thus I'm gonna have to close this for now as it's not feasible to include in the current version. Perhaps 3.x will make this more doable, but it's still unlikely. I am, however, still open to suggestions on how this could work. |
Ok. I've ended up thinking that a custom help is the best solution. |
Bah, I'm gonna keep this open. It is something I'd like to have. It probably won't happen soon, but I do want this style of feature. |
Adding my vote for this feature. My Fuchsia-specific cargo wrapper Fargo could really benefit from it. |
I'm trying to get 3.x out the door in the coming weeks so I can start knocking out all the current feature/bug reports. This particular feature is high on my list though 😉 |
Args can now be added to custom help sections. This breaks up the builder pattern a little by adding help section declarations inline, but it's the most intuitive method and doesn't require strange nesting that feels awkward. ```rust app::new("foo") .arg(Arg::with_name("arg1")) // under normal headers .help_heading("SPECIAL") .arg(Arg::with_name("arg2")) // under SPECIAL: heading ``` Closes clap-rs#805
Args can now be added to custom help sections. This breaks up the builder pattern a little by adding help section declarations inline, but it's the most intuitive method and doesn't require strange nesting that feels awkward. ```rust app::new("foo") .arg(Arg::with_name("arg1")) // under normal headers .help_heading("SPECIAL") .arg(Arg::with_name("arg2")) // under SPECIAL: heading ``` Closes clap-rs#805
Closed with #1211 (will be released in v3) |
Hello. I want to group options into categories, like this. See: Elements, Attributes, Paths, etc.
It there a way to do this in the current
clap
version or is it will be implemented?The text was updated successfully, but these errors were encountered: