-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
Return help message as String for Command #3873
Comments
We do have Command::write_help so its possible to do this today. The interesting part to me is that for help, we have a
|
Well the question is about
I think this function might work but would require a lot of missing around in my opinion, and for my use case I would like it simply rendered as a String. The thing is, I think there should be a
|
To be clear, my point about btw a quick example for fn main() {
let mut cmd = clap::Command::new("myprog");
let mut out: Vec<u8> = Vec::new();
cmd.write_help(&mut out).expect("failed to write to buffer");
let out = String::from_utf8(out).expect("help is utf-8");
dbg!(&out);
} Beyond a
Random thoughts on the proposal to simplify things for people who just want a
Thinking through that, I think I am fine with moving forward with this as long as the review churn ends up being low. |
@ychiguer how come this is closed? The related PR isn't merged yet and generally Issues are closed as completed when their PR is merged and github will do this automatically if you use the right syntax. See https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword |
Must have done it by mistake. |
The writer is less convenient and isn't offering any performance benefits of avoidign the extra allocations, so let's render instead. This supersedes clap-rs#3874 Fixes clap-rs#3873
The writer is less convenient and isn't offering any performance benefits of avoidign the extra allocations, so let's render instead. This supersedes clap-rs#3874 Fixes clap-rs#3873
Please complete the following tasks
Clap Version
3.1.18
Describe your use case
The only way I could find to use the help message is to print out it to
Stdout
. In my use case I would like to get the help message as a String as I intend to not print it toStdout
directly.Describe the solution you'd like
A function that returns the help message as a String.
Alternatives, if applicable
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered: