From 82520e63ba1dcda0b8d82d40d3fe4bff96e96295 Mon Sep 17 00:00:00 2001 From: Username404 Date: Tue, 21 Sep 2021 21:45:31 +0200 Subject: [PATCH] Handle the "--version" argument when iterating on argc --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index d5674b7..d1bfd4a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -10,7 +10,6 @@ using namespace std; #include "headers/transpiler/Target.hpp" int main(int argc, char* argv[]) { - if ((argc == 2) && (((string) argv[1]) == "--version")) { cout << Yerbacon::getVersion() << endl; exit(EXIT_SUCCESS); } string target = ".lua"; bool printResult = false; bool parallel = false; @@ -21,7 +20,8 @@ int main(int argc, char* argv[]) { for (signed int i = 0; i < argc; ++i) { const string_view currentArg (argv[i]); - if (currentArg == ArgumentShort("printresult")) printResult = true; + if ((argc == 2) && (currentArg == Argument("version"))) { cout << Yerbacon::getVersion() << endl; exit(EXIT_SUCCESS); } + else if (currentArg == ArgumentShort("printresult")) printResult = true; else if (currentArg == ArgumentAssignable("target")) { const string value = ArgumentAssignable::getValueFor(currentArg.data()); if (!value.empty()) (target = '.') += value;