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