diff --git a/src/cxxopts.cpp b/src/cxxopts.cpp index c1b4b21..3579541 100644 --- a/src/cxxopts.cpp +++ b/src/cxxopts.cpp @@ -101,14 +101,16 @@ namespace cxxopts result.append(startLine, current + 1); result.append("\n"); result.append(start, ' '); + startLine = current + 1; + lastSpace = startLine; } else { - result.append(startLine, current); + result.append(startLine, lastSpace); result.append("\n"); result.append(start, ' '); + startLine = lastSpace + 1; } - startLine = lastSpace + 1; size = 0; } else @@ -405,7 +407,7 @@ Options::help() const longest = std::min(longest, static_cast(OPTION_LONGEST)); //widest allowed description - int allowed = 78 - longest - OPTION_DESC_GAP; + int allowed = 76 - longest - OPTION_DESC_GAP; auto fiter = format.begin(); for (const auto& o : group->second) diff --git a/src/example.cpp b/src/example.cpp index 37c2f30..fa0e322 100644 --- a/src/example.cpp +++ b/src/example.cpp @@ -40,6 +40,8 @@ int main(int argc, char* argv[]) ("positional", "Positional arguments: these are the arguments that are entered " "without an option", cxxopts::value()) + ("long-description", + "thisisareallylongwordthattakesupthewholelineandcannotbebrokenataspace") ("help", "Print help") ;