|
8 | 8 |
|
9 | 9 | #include "parse_options.h" |
10 | 10 |
|
11 | | -#include <algorithm> |
12 | | -#include <cctype> |
13 | 11 | #include <climits> |
14 | 12 |
|
15 | 13 | #if defined (_WIN32) |
@@ -178,54 +176,3 @@ banner_string(const std::string &front_end, const std::string &version) |
178 | 176 |
|
179 | 177 | return align_center_with_border(version_str); |
180 | 178 | } |
181 | | - |
182 | | -std::string help_entry( |
183 | | - const std::string &option, |
184 | | - const std::string &description, |
185 | | - const std::size_t left_margin, |
186 | | - const std::size_t width) |
187 | | -{ |
188 | | - PRECONDITION(!option.empty()); |
189 | | - PRECONDITION(!std::isspace(option.front())); |
190 | | - PRECONDITION(!std::isspace(option.back())); |
191 | | - PRECONDITION(option.length() <= width); |
192 | | - |
193 | | - PRECONDITION(!description.empty()); |
194 | | - PRECONDITION(!std::isspace(description.front())); |
195 | | - PRECONDITION(!std::isspace(description.back())); |
196 | | - |
197 | | - PRECONDITION(left_margin < width); |
198 | | - |
199 | | - std::string result; |
200 | | - |
201 | | - if(option.length() >= left_margin - 1) |
202 | | - { |
203 | | - result = " " + option + "\n"; |
204 | | - result += wrap_line(description, left_margin, width) + "\n"; |
205 | | - |
206 | | - return result; |
207 | | - } |
208 | | - |
209 | | - std::string padding(left_margin - option.length() - 1, ' '); |
210 | | - result = " " + option + padding; |
211 | | - |
212 | | - if(description.length() <= (width - left_margin)) |
213 | | - { |
214 | | - return result + description + "\n"; |
215 | | - } |
216 | | - |
217 | | - auto it = description.cbegin() + (width - left_margin); |
218 | | - auto rit = std::reverse_iterator<decltype(it)>(it) - 1; |
219 | | - |
220 | | - auto rit_space = std::find(rit, description.crend(), ' '); |
221 | | - auto it_space = rit_space.base() - 1; |
222 | | - CHECK_RETURN(*it_space == ' '); |
223 | | - |
224 | | - result.append(description.cbegin(), it_space); |
225 | | - result.append("\n"); |
226 | | - |
227 | | - result += |
228 | | - wrap_line(it_space + 1, description.cend(), left_margin, width) + "\n"; |
229 | | - |
230 | | - return result; |
231 | | -} |
0 commit comments