main.cpp: Rename "currentArg" to "currentArgument"

Signed-off-by: Username404 <w.iron.zombie@gmail.com>
This commit is contained in:
Username404 2022-04-09 22:53:45 +02:00
parent 21137f5beb
commit 6945900140
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
1 changed files with 18 additions and 18 deletions

View File

@ -21,55 +21,55 @@ int main(int argc, char* argv[]) {
map<string_view, unit> Units; map<string_view, unit> Units;
for (signed int i = 1; i < argc; ++i) for (signed int i = 1; i < argc; ++i)
{ {
const string_view currentArg (argv[i]); const string_view currentArgument (argv[i]);
if (currentArg == ArgumentShort("printresult")) printResult = true; if (currentArgument == ArgumentShort("printresult")) printResult = true;
else if (currentArg == ArgumentAssignable("target")) { else if (currentArgument == ArgumentAssignable("target")) {
const string_view value = ArgumentAssignable::getValueFor(currentArg); const string_view value = ArgumentAssignable::getValueFor(currentArgument);
if (not value.empty()) target = value; if (not value.empty()) target = value;
else Yerbacon::fail("No target was provided."); else Yerbacon::fail("No target was provided.");
} }
else if (currentArg == Argument("parallel")) parallel = true; else if (currentArgument == Argument("parallel")) parallel = true;
else if (currentArg == ArgumentAssignable("newlines")) { else if (currentArgument == ArgumentAssignable("newlines")) {
const string_view enabled = ArgumentAssignable::getValueFor(currentArg); const string_view enabled = ArgumentAssignable::getValueFor(currentArgument);
if (enabled == "off") { if (enabled == "off") {
newLines = false; newLines = false;
} else if (enabled == "on") { } else if (enabled == "on") {
newLines = true; newLines = true;
} else goto invalid_argument; } else goto invalid_argument;
} }
else if (currentArg == ArgumentShort("text")) { text_provided = true; printResult = true; } else if (currentArgument == ArgumentShort("text")) { text_provided = true; printResult = true; }
else if ((currentArg.ends_with(".ybcon") && !text_provided) || text_provided) else if ((currentArgument.ends_with(".ybcon") && !text_provided) || text_provided)
Units.insert_or_assign(currentArg, async(not parallel ? launch::deferred : launch::async, [currentArg, &text_provided, &target, &newLines]() { Units.insert_or_assign(currentArgument, async(not parallel ? launch::deferred : launch::async, [currentArgument, &text_provided, &target, &newLines]() {
unit_result resultingPair; unit_result resultingPair;
try { try {
resultingPair.first = Target::forName(target, newLines)->transpileWithTree( resultingPair.first = Target::forName(target, newLines)->transpileWithTree(
parseString(text_provided ? currentArg : getFileContent(currentArg.data())) parseString(text_provided ? currentArgument : getFileContent(currentArgument.data()))
); );
if (not text_provided) outputFileContent(string(currentArg.substr(0, currentArg.size() - 6)) + '.' + target, resultingPair.first); if (not text_provided) outputFileContent(string(currentArgument.substr(0, currentArgument.size() - 6)) + '.' + target, resultingPair.first);
} catch (const Yerbacon::Exception& error) { } catch (const Yerbacon::Exception& error) {
size_t lastSlash = 0; size_t lastSlash = 0;
const size_t position1 = currentArg.find_last_of('/'); const size_t position1 = currentArgument.find_last_of('/');
if (cmp_not_equal(position1, string_view::npos)) lastSlash = position1; if (cmp_not_equal(position1, string_view::npos)) lastSlash = position1;
if constexpr(filesystem::path::preferred_separator != '/') { if constexpr(filesystem::path::preferred_separator != '/') {
const size_t position2 = currentArg.find_last_of(filesystem::path::preferred_separator); const size_t position2 = currentArgument.find_last_of(filesystem::path::preferred_separator);
if (cmp_not_equal(position2, string_view::npos)) { if (cmp_not_equal(position2, string_view::npos)) {
lastSlash = max(lastSlash, position2); lastSlash = max(lastSlash, position2);
} }
} }
resultingPair.first = currentArg.substr(lastSlash + 1); resultingPair.first = currentArgument.substr(lastSlash + 1);
resultingPair.second.emplace(error); resultingPair.second.emplace(error);
} }
return resultingPair; return resultingPair;
})); }));
else { else {
if (argc == 2) { if (argc == 2) {
if (currentArg == Argument("version")) { if (currentArgument == Argument("version")) {
cout << Yerbacon::getVersion(); cout << Yerbacon::getVersion();
} else if (currentArg == Argument("buildInfo")) { } else if (currentArgument == Argument("buildInfo")) {
cout << Yerbacon::getBuildInfo(); cout << Yerbacon::getBuildInfo();
} else goto invalid_argument; } else goto invalid_argument;
cout << '\n'; exit(EXIT_SUCCESS); cout << '\n'; exit(EXIT_SUCCESS);
} else invalid_argument: Yerbacon::fail({"\"", currentArg.data(), "\" is not a valid argument."}); } else invalid_argument: Yerbacon::fail({"\"", currentArgument.data(), "\" is not a valid argument."});
} }
} }
if (!Units.empty()) { if (!Units.empty()) {