From ffcde408e1032a3a9a859c76098bd09dcaad04e2 Mon Sep 17 00:00:00 2001 From: Riyyi Date: Mon, 13 Sep 2021 12:04:44 +0200 Subject: [PATCH] Util: Add invalid argument type error message to ArgParser --- src/util/argparser.cpp | 6 ++++++ src/util/argparser.h | 1 + 2 files changed, 7 insertions(+) diff --git a/src/util/argparser.cpp b/src/util/argparser.cpp index d076661..148e557 100644 --- a/src/util/argparser.cpp +++ b/src/util/argparser.cpp @@ -51,6 +51,9 @@ void ArgParser::printOptionError(const char* name, Error error, bool longName) printf("%s: option requires an argument -- '%s'\n", m_name, name); } } + else if (error == Error::InvalidArgumentType) { + printf("%s: invalid argument type '%s'\n", m_name, name); + } // TODO: Print command usage, if it's enabled. } @@ -217,6 +220,9 @@ bool ArgParser::parseArgument(std::string_view argument) m_argumentIndex++; continue; } + else { + printOptionError(argument.data(), Error::InvalidArgumentType); + } break; } diff --git a/src/util/argparser.h b/src/util/argparser.h index 0a44048..d195851 100644 --- a/src/util/argparser.h +++ b/src/util/argparser.h @@ -29,6 +29,7 @@ public: ExtraOperand, // For arguments DoesntAllowArgument, RequiresArgument, + InvalidArgumentType, }; struct Option {