Commit abf96da6975287f5a2391e57045204206e656b81

Authored by Jarryd Beck
1 parent 2e4c7880

fix description formatting

src/cxxopts.cpp
... ... @@ -101,14 +101,16 @@ namespace cxxopts
101 101 result.append(startLine, current + 1);
102 102 result.append("\n");
103 103 result.append(start, ' ');
  104 + startLine = current + 1;
  105 + lastSpace = startLine;
104 106 }
105 107 else
106 108 {
107   - result.append(startLine, current);
  109 + result.append(startLine, lastSpace);
108 110 result.append("\n");
109 111 result.append(start, ' ');
  112 + startLine = lastSpace + 1;
110 113 }
111   - startLine = lastSpace + 1;
112 114 size = 0;
113 115 }
114 116 else
... ... @@ -405,7 +407,7 @@ Options::help() const
405 407 longest = std::min(longest, static_cast<size_t>(OPTION_LONGEST));
406 408  
407 409 //widest allowed description
408   - int allowed = 78 - longest - OPTION_DESC_GAP;
  410 + int allowed = 76 - longest - OPTION_DESC_GAP;
409 411  
410 412 auto fiter = format.begin();
411 413 for (const auto& o : group->second)
... ...
src/example.cpp
... ... @@ -40,6 +40,8 @@ int main(int argc, char* argv[])
40 40 ("positional",
41 41 "Positional arguments: these are the arguments that are entered "
42 42 "without an option", cxxopts::value<std::string>())
  43 + ("long-description",
  44 + "thisisareallylongwordthattakesupthewholelineandcannotbebrokenataspace")
43 45 ("help", "Print help")
44 46 ;
45 47  
... ...