From f021cf0e151c5cfc2d10023d332871421b31392f Mon Sep 17 00:00:00 2001 From: Riyyi Date: Tue, 7 Sep 2021 00:54:16 +0200 Subject: [PATCH] Util: Fix parsing for exit on first error setting --- src/util/argparser.cpp | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/src/util/argparser.cpp b/src/util/argparser.cpp index 76bde12..9121f8c 100644 --- a/src/util/argparser.cpp +++ b/src/util/argparser.cpp @@ -76,8 +76,7 @@ bool ArgParser::parseShortOption(std::string_view option, std::string_view next) return result; } } - - if (foundOption->requiresArgument == Required::No) { + else if (foundOption->requiresArgument == Required::No) { // FIXME: Figure out why providing a nullptr breaks the lambda here. result = foundOption->acceptValue(""); } @@ -144,24 +143,16 @@ bool ArgParser::parseLongOption(std::string_view option, std::string_view next) }); if (foundOption == m_options.cend()) { - foundOption->error = Error::UnrecognizedOption; printOptionError(name.data(), Error::UnrecognizedOption); result = false; - if (m_exitOnFirstError) { - return result; - } } - - if (argumentProvided) { + else if (argumentProvided) { if (foundOption->requiresArgument == Required::No) { foundOption->error = Error::DoesntAllowArgument; printOptionError(name.data(), Error::DoesntAllowArgument); result = false; - if (m_exitOnFirstError) { - return result; - } } else if (foundOption->requiresArgument == Required::Yes) { result = foundOption->acceptValue(value.data()); @@ -176,9 +167,6 @@ bool ArgParser::parseLongOption(std::string_view option, std::string_view next) printOptionError(name.data(), Error::RequiresArgument); result = false; - if (m_exitOnFirstError) { - return result; - } } else { result = foundOption->acceptValue(next.data()); @@ -190,9 +178,6 @@ bool ArgParser::parseLongOption(std::string_view option, std::string_view next) printOptionError(name.data(), Error::RequiresArgument); result = false; - if (m_exitOnFirstError) { - return result; - } } else { // FIXME: Figure out why providing a nullptr breaks the lambda here.