332{
333
334 auto wrap = [](const std::string& text, size_t line_length) -> std::string {
335 std::istringstream words(text);
336 std::ostringstream wrapped;
337 std::string word;
338
339 if (words >> word) {
340 wrapped << word;
341 size_t space_left = line_length - word.length();
342 while (words >> word) {
343 if (space_left < word.length() + 1) {
344 wrapped << '\n' << word;
345 space_left = line_length - word.length();
346 } else {
347 wrapped << ' ' << word;
348 space_left -= word.length() + 1;
349 }
350 }
351 }
352 return wrapped.str();
353 };
354
355
356 std::set<std::string> categories;
357 for (
const auto& opt : this->
options) {
358 const ConfigOptionDef& def = opt.second;
359 if (filter(def))
360 categories.insert(def.category);
361 }
362
363 for (const std::string& category : categories) {
364 if (category != "") {
365 out << category << ":" << std::endl;
366 } else if (categories.size() > 1) {
367 out << "Misc options:" << std::endl;
368 }
369
370 for (
const auto& opt : this->
options) {
371 const ConfigOptionDef& def = opt.second;
373 continue;
374
375
376 std::vector<std::string> cli_args = def.cli_args(opt.first);
377 if (cli_args.empty())
378 continue;
379
380 for (
auto&
arg : cli_args) {
381 arg.insert(0, (
arg.size() == 1) ?
"-" :
"--");
385 }
else if (def.type ==
coPoint) {
391 }
392 }
393
394
395 const std::string cli = boost::algorithm::join(cli_args, ", ");
396 out << " " << std::left << std::setw(20) << cli;
397
398
399 std::string descr = def.tooltip;
400 bool show_defaults_this = show_defaults || def.opt_key == "config_compatibility";
401 if (show_defaults_this && def.default_value && def.type !=
coBool
402 && (def.type !=
coString || !def.default_value->serialize().empty())) {
403 descr += " (";
404 if (!def.sidetext.empty()) {
405 descr += def.sidetext + ", ";
406 } else if (def.enum_def->has_values()) {
407 descr += boost::algorithm::join(def.enum_def->values(), ", ") + "; ";
408 }
409 descr += "default: " + def.default_value->serialize() + ")";
410 }
411
412
413 descr = wrap(descr, 80);
414 std::vector<std::string> lines;
415 boost::split(lines, descr, boost::is_any_of("\n"));
416
417
418 for (size_t i = 0; i < lines.size(); ++i) {
419 if (i == 0 && cli.size() > 19)
420 out << std::endl;
421 if (i > 0 || cli.size() > 19)
422 out << std::string(21, ' ');
423 out << lines[i] << std::endl;
424 }
425 }
426 }
427 return out;
428}
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const ArgReturnType arg() const
Definition ArrayCwiseUnaryOps.h:57
static const constexpr char * nocli
Definition Config.hpp:2035
@ coPoint
Definition Config.hpp:184
@ coPoint3
Definition Config.hpp:187
@ coBool
Definition Config.hpp:190
@ coFloats
Definition Config.hpp:166