mirror of
https://github.com/sametersoylu/argument-parser.git
synced 2026-05-28 20:08:10 +00:00
chore: add missing definitions to the files. remove static qualifier from the headers. add help text to the actions.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 << "] ";
|
||||
|
||||
Reference in New Issue
Block a user