chore: add missing definitions to the files. remove static qualifier from the headers. add help text to the actions.

This commit is contained in:
2026-03-15 23:55:06 +04:00
parent 9e646622db
commit 3552d34dac
5 changed files with 33 additions and 13 deletions

View File

@@ -2,12 +2,12 @@
#include <algorithm>
namespace argument_parser::conventions::helpers {
static std::string to_lower(std::string s) {
std::string to_lower(std::string s) {
std::transform(s.begin(), s.end(), s.begin(), [](unsigned char c) { return std::tolower(c); });
return s;
}
static std::string to_upper(std::string s) {
std::string to_upper(std::string s) {
std::transform(s.begin(), s.end(), s.begin(), [](unsigned char c) { return std::toupper(c); });
return s;
}

View File

@@ -27,6 +27,10 @@ namespace argument_parser {
return *this;
}
bool argument::expects_parameter() const {
return action->expects_parameter();
}
bool argument::is_required() const {
return required;
}
@@ -181,13 +185,13 @@ namespace argument_parser {
std::initializer_list<conventions::convention const *const> convention_types) {
std::vector<std::pair<std::string, std::string>> required_args;
for (auto const &[key, arg] : argument_map) {
if (arg.is_required() and not arg.is_invoked()) {
if (arg.is_required() && !arg.is_invoked()) {
required_args.emplace_back<std::pair<std::string, std::string>>(
{reverse_short_arguments[key], reverse_long_arguments[key]});
}
}
if (not required_args.empty()) {
if (!required_args.empty()) {
std::cerr << "These arguments were expected but not provided: ";
for (auto const &[s, l] : required_args) {
std::cerr << "[-" << s << ", --" << l << "] ";