| 21 | #endif |
| 22 | |
| 23 | void printWrap(std::ostream& os, int leftPad, const std::string& content) { |
| 24 | int len = content.size(); |
| 25 | int space = SCREEN_WIDTH - leftPad; |
| 26 | std::string nextWord; |
| 27 | std::string pad(leftPad, ' '); |
| 28 | for (int i = 0; i <= len; ++i) { |
| 29 | if (i != len && content[i] != ' ' && content[i] != '\n') { |
| 30 | nextWord += content[i]; |
| 31 | } else { |
| 32 | if (static_cast<int>(nextWord.size()) > space) { |
| 33 | os << '\n' << pad; |
| 34 | space = SCREEN_WIDTH - leftPad; |
| 35 | } |
| 36 | os << nextWord; |
| 37 | space -= nextWord.size() + 1; |
| 38 | if (space > 0) { |
| 39 | os << ' '; |
| 40 | } |
| 41 | nextWord.clear(); |
| 42 | if (content[i] == '\n') { |
| 43 | os << '\n'; |
| 44 | space = SCREEN_WIDTH - leftPad; |
| 45 | } |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | Options::Options(const std::string& command, const std::string& description) |
| 51 | : debug(false), positional(Arguments::Zero) { |