diff options
Diffstat (limited to 'cli')
| -rw-r--r-- | cli/ManifestBuilder.cc (renamed from cli/CliApp.cc) | 50 |
1 files changed, 23 insertions, 27 deletions
diff --git a/cli/CliApp.cc b/cli/ManifestBuilder.cc index f8fd999..2c9c4ad 100644 --- a/cli/CliApp.cc +++ b/cli/ManifestBuilder.cc @@ -3,41 +3,38 @@ // Copyright ZKA Web Services. // ============================================================= // -#include <Macros.h> #include <JSONManifestBuilder.h> -#include <cstdio> -#include <cstddef> -#include <string> -#include <iostream> -#include <thread> +#include <Includes.h> -static int cJobIndex = 0; -static bool cFailed = false; +static int kJobCount = 0; +static bool kFailed = false; int main(int argc, char** argv) { - cJobIndex = argc - 1; + if (argc <= 1) + return -1; + + kJobCount = argc - 1; for (size_t index = 1; index < argc; ++index) { std::string index_path = argv[index]; - if (index_path == "/Ver" || - index_path == "/Version") + if (index_path == "-v" || + index_path == "--version") { std::cout << "Usage: btb <file>\n"; std::cout << "Check for issues at: www.el-mahrouss-logic.com/btb/issues\n"; std::cout << "Brought to you by Amlal El Mahrouss.\n"; - std::cout << "© ZKA Web Services, all rights reserved.\n"; + std::cout << "© ZKA Web Services Co, all rights reserved.\n"; return 0; } - else if (index_path == "/?" || - index_path == "/Help") + else if (index_path == "-h" || + index_path == "--help") { std::cout << "btb: Build a JSON file: btb <json_path>.json\n"; - std::cout << "btb: Build a TOML file: btb <toml_path>.toml\n"; return 0; } @@ -45,47 +42,46 @@ int main(int argc, char** argv) std::thread job_build_thread([](std::string index_path) -> void { IManifestBuilder* builder = nullptr; - const auto cJsonExt = ".json"; + const auto kJsonExtension = ".json"; - if (index_path.ends_with(cJsonExt)) + if (index_path.ends_with(kJsonExtension)) { builder = new JSONManifestBuilder(); } else { - cFailed = true; + kFailed = true; return; } std::cout << "btb: building: " << index_path << std::endl; - if (builder && !builder->Build(index_path.size(), index_path.c_str())) + if (builder && !builder->buildTarget(index_path.size(), index_path.c_str())) { - cFailed = true; + kFailed = true; } else if (!builder) { - cFailed = true; + kFailed = true; } delete builder; - --cJobIndex; - }, - index_path); + --kJobCount; + }, index_path); job_build_thread.detach(); } // wait for completion of all jobs. - while (cJobIndex) + while (kJobCount) { - if (cFailed) + if (kFailed) { std::cout << "btb: build failed: " << errno << "." << std::endl; return EXIT_FAILURE; } } - return cFailed ? EXIT_FAILURE : EXIT_SUCCESS; + return kFailed ? EXIT_FAILURE : EXIT_SUCCESS; } |
