Flags: show default value.
This commit is contained in:
parent
f76d524999
commit
33675c18ec
|
@ -1,6 +1,6 @@
|
|||
cmake_minimum_required(VERSION 3.22)
|
||||
project(scsl LANGUAGES CXX
|
||||
VERSION 1.1.1
|
||||
VERSION 1.1.2
|
||||
DESCRIPTION "Shimmering Clarity Standard Library")
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace geom {
|
|||
/// and rotations in three dimensions.
|
||||
///
|
||||
/// Quaternions encode rotations in three-dimensional space. While
|
||||
/// technically a MakeQuaternion is comprised of a real element and a
|
||||
/// technically a Quaternion is comprised of a real element and a
|
||||
/// complex vector<3>, for the purposes of this library, it is modeled
|
||||
/// as a floating point 4D vector of the form <w, x, y, z>, where x, y,
|
||||
/// and z represent an Axis of rotation in R3 and w the Angle, in
|
||||
|
|
|
@ -25,9 +25,9 @@
|
|||
#include <regex>
|
||||
#include <utility>
|
||||
|
||||
#include <vector>
|
||||
#include <scsl/Flags.h>
|
||||
#include <scsl/StringUtil.h>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace scsl {
|
||||
|
@ -300,7 +300,6 @@ Flags::Parse(int argc, char **argv, bool skipFirst)
|
|||
throw std::runtime_error("unhandled parse state");
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return ParseStatus::OK;
|
||||
|
@ -313,26 +312,44 @@ Flags::Usage(std::ostream &os, int exitCode)
|
|||
os << this->name << ":\t";
|
||||
auto indent = this->name.size() + 7;
|
||||
|
||||
scstring::WriteTabIndented(os, description, 72 - indent, indent / 8, false);
|
||||
scstring::WriteTabIndented(os, this->description, 72 - indent,
|
||||
indent / 8, false);
|
||||
os << "\n\n";
|
||||
|
||||
for (const auto &pair: this->flags) {
|
||||
auto argDesc = pair.second->Description;
|
||||
if (!argDesc.empty()) {
|
||||
argDesc += ' ';
|
||||
}
|
||||
auto argLine = "\t" + pair.first;
|
||||
switch (pair.second->Type) {
|
||||
case FlagType::Boolean:
|
||||
argLine += "\t\t";
|
||||
argDesc += "(default=false)";
|
||||
break;
|
||||
case FlagType::Integer:
|
||||
argLine += " int\t\t";
|
||||
if (pair.second->Value.i != 0) {
|
||||
argDesc += "(default=" + std::to_string(pair.second->Value.i) + ")";
|
||||
}
|
||||
break;
|
||||
case FlagType::UnsignedInteger:
|
||||
argLine += " uint\t\t";
|
||||
if (pair.second->Value.u != 0) {
|
||||
argDesc += "(default=" + std::to_string(pair.second->Value.u) + ")";
|
||||
}
|
||||
break;
|
||||
case FlagType::SizeT:
|
||||
argLine += " size_t\t";
|
||||
if (pair.second->Value.size != 0) {
|
||||
argDesc += "(default=" + std::to_string(pair.second->Value.size) + ")";
|
||||
}
|
||||
break;
|
||||
case FlagType::String:
|
||||
argLine += " string\t";
|
||||
if (pair.second->Value.s != nullptr && !(pair.second->Value.s->empty())) {
|
||||
argDesc += "(default=" + *(pair.second->Value.s) + ")";
|
||||
}
|
||||
break;
|
||||
case FlagType::Unknown:
|
||||
// fallthrough
|
||||
|
@ -347,8 +364,8 @@ Flags::Usage(std::ostream &os, int exitCode)
|
|||
|
||||
os << argLine;
|
||||
indent = argLine.size();
|
||||
scstring::WriteTabIndented(os, pair.second->Description,
|
||||
72-indent, (indent/8)+2, false);
|
||||
scstring::WriteTabIndented(os, argDesc, 72 - indent,
|
||||
(indent / 8) + 2, false);
|
||||
}
|
||||
|
||||
os << "\n";
|
||||
|
@ -456,4 +473,3 @@ Flags::GetString(std::string fName, std::string &flagValue)
|
|||
|
||||
|
||||
}// namespace scsl
|
||||
|
||||
|
|
Loading…
Reference in New Issue