|
|
|
|
@ -1,6 +1,8 @@
|
|
|
|
|
|
|
|
|
|
#include "cb/argparser/argument_parser.h"
|
|
|
|
|
|
|
|
|
|
#include <format>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cb::argparser::Argument::Argument(std::string content, cb::argparser::Type type) : content{std::move(content)}, type{type} {
|
|
|
|
|
if (type == Type::BOOL_TYPE && this->content == "false") {
|
|
|
|
|
@ -179,3 +181,28 @@ void cb::argparser::ArgumentParser::add_argument(const std::string &short_name,
|
|
|
|
|
assert(type == Type::INTEGER_TYPE);
|
|
|
|
|
add_argument(short_name, name, type, std::move(description), std::to_string(default_value), mode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string cb::argparser::ArgumentParser::get_help() {
|
|
|
|
|
std::string help_message{};
|
|
|
|
|
if (not positional_arguments.empty()) {
|
|
|
|
|
help_message += "Positional Arguments:\n";
|
|
|
|
|
for (auto &&arg: positional_arguments) {
|
|
|
|
|
help_message += std::format("{:15} {}\n",
|
|
|
|
|
arg.name,
|
|
|
|
|
arg.description);
|
|
|
|
|
}
|
|
|
|
|
help_message += "\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (not arguments.empty()) {
|
|
|
|
|
help_message += "Arguments:\n";
|
|
|
|
|
for (auto &&arg: arguments) {
|
|
|
|
|
help_message += std::format("{:5} {:15} {}\n",
|
|
|
|
|
arg.short_name,
|
|
|
|
|
arg.name,
|
|
|
|
|
arg.description);
|
|
|
|
|
}
|
|
|
|
|
help_message += "\n";
|
|
|
|
|
}
|
|
|
|
|
return help_message;
|
|
|
|
|
}
|
|
|
|
|
|