-
Notifications
You must be signed in to change notification settings - Fork 591
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
Doesn't wrap help_string
if it's too long
#321
Comments
Can you tell me a bit more about your usage? I haven't been able to recreate the issue. 110+ character string wraps fine for me. |
I am trying to do the following: #include <cxxopts.hpp>
#include <iostream>
int main(int argc, char **argv) {
cxxopts::Options opts("my_cli", "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.");
opts.add_options()
("h,help", "Show help");
auto result = opts.parse(argc, argv);
if (result.count("help")) {
std::cout << opts.help() << std::endl;
return 0;
}
std::cout << "Normal execution." << std::endl;
return 0;
} What I get:
The first line isn't wrapped and is more than 80 characters long. Maybe I am misusing this argument of |
You are correct. I forgot my output was set to automatically wrap. I do believe the purpose of |
Is wrapping not automatic? I think I always wanted the default to be 80
characters, so that can be changed.
…On Sat, 1 Jan 2022, 9:13 am Ben Graham, ***@***.***> wrote:
You are correct. I forgot my output was set to automatically wrap. I do
believe the purpose of help_string is to be short and brief. However,
@jarro2783 <https://github.com/jarro2783> would you be opposed to
automatic wrapping?
—
Reply to this email directly, view it on GitHub
<#321 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AALDQ4RSVAK6TESZEL34YN3UTYTI7ANCNFSM5KY3K6TQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I believe only the option descriptions are wrapped, not the Example: #include "cxxopts.hpp"
#include <iostream>
std::string longStr = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
int main(int argc, char **argv) {
cxxopts::Options opts("my_cli", longStr);
opts.set_width(80); // controls width of option description
opts.add_options()
("h,help", longStr);
auto result = opts.parse(argc, argv);
if (result.count("help")) {
std::cout << opts.help() << std::endl;
return 0;
}
std::cout << "Normal execution." << std::endl;
return 0;
} Output:
|
Ah I missed that it was the main description. I think that can be wrapped
by default too.
…On Sat, 1 Jan 2022, 11:17 am Ben Graham, ***@***.***> wrote:
I believe only the option descriptions are wrapped, not the help_string
itself.
Example:
#include "cxxopts.hpp"
#include <iostream>
std::string longStr = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
int main(int argc, char **argv) {
cxxopts::Options opts("my_cli", longStr);
opts.set_width(80); // controls width of option description
opts.add_options()
("h,help", longStr);
auto result = opts.parse(argc, argv);
if (result.count("help")) {
std::cout << opts.help() << std::endl;
return 0;
}
std::cout << "Normal execution." << std::endl;
return 0;
}
Output:
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Usage:
my_cli [OPTION...]
-h, --help Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut
enim ad minim veniam, quis nostrud exercitation ullamco laboris
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat
nulla pariatur. Excepteur sint occaecat cupidatat non proident,
sunt in culpa qui officia deserunt mollit anim id est laborum.
—
Reply to this email directly, view it on GitHub
<#321 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AALDQ4RQFKI2Z4MUWNZAFFTUTZB3JANCNFSM5KY3K6TQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
If so, I can't figure out how! As far as I can tell from Lines 2660 to 2661 in ad2d1a6
|
I just looked into this, and I see that there is no wrapping. I would have to write a bit of code to do that. |
I have
where
"long string..."
is quite long (more than 80 characters). I expect it to be wrapped across multiple lines, but cxxopts just prints it as-is, without wrapping.The text was updated successfully, but these errors were encountered: