-
Notifications
You must be signed in to change notification settings - Fork 150
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
It must be possible to not call author and about clap method #31
Comments
StructOpt doesn't do anything about that, clap does. You want that: https://docs.rs/clap/2.27.1/clap/enum.AppSettings.html#variant.DeriveDisplayOrder Using structopt: extern crate clap;
extern crate structopt;
#[macro_use]
extern crate structopt_derive;
use structopt::StructOpt;
#[derive(StructOpt, Debug)]
#[structopt(setting_raw = "clap::AppSettings::DeriveDisplayOrder")]
struct Opt {
#[structopt(short = "s")]
speed: bool,
#[structopt(short = "d")]
debug: bool,
}
fn main() {
let opt = Opt::from_args();
println!("{:?}", opt);
} It gives:
Does it answer your question? |
Thanks! Is there also a way to display the ARGS before OPTIONS and FLAGS? |
I can't find any similar feature in clap. |
By convention, ARGS will always be at the end on the USAGE line, because you can use Thus, I think clap will not allow such a thing. |
Ah ok, and how can I not include the about or author info in structopt? |
Sorry for chiming in, but just to be sure: @Boscop did you check the Clap documentation for how to do it there? If yes and it is indeed possible to perform it with Clap, what troubles did you have translating that into StructOpt? |
In clap it's done with |
If I pass How can I tell Structopt to not do these calls if the strings are empty? (So there will always be only 1 line space between the line containing |
You're right, that's not possible for the moment. I'll manage the case empty string to not call the clap method on author and about. |
v0.1.6 published |
Thanks! |
I just switched from 0.1 to 0.2 and this doesn't work anymore: What's the right way to do this now? |
The changelog explain everything. Here, that's |
Format code with rustfmt
StructOpt will always call to author and about method. There should be a way to avoid these call. The goal is that if the value is the empty string, no call will be performed.
The issue originally was:
Order of args in --help should be in the order that fields appear in the options struct.
E.g. I want to have
-i
shown before-o
in--help
, but even though I put it before it in the struct, it appears after it in--help
, why?The text was updated successfully, but these errors were encountered: