From 40a11d15d51c0fdfb93003d97aae6fc0c4538890 Mon Sep 17 00:00:00 2001 From: Amlal EL Mahrouss Date: Wed, 9 Oct 2024 12:46:15 +0200 Subject: IMP: Improved ReadMe and support pwsh for run_after_build command. Signed-off-by: Amlal EL Mahrouss --- cli/AppMain.cxx | 85 ----------------------------------------------------- cli/CliApp.cxx | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+), 85 deletions(-) delete mode 100644 cli/AppMain.cxx create mode 100644 cli/CliApp.cxx (limited to 'cli') diff --git a/cli/AppMain.cxx b/cli/AppMain.cxx deleted file mode 100644 index 6719c19..0000000 --- a/cli/AppMain.cxx +++ /dev/null @@ -1,85 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -static int cJobIndex = 0; -static bool cFailed = false; - -int main(int argc, char** argv) -{ - cJobIndex = argc - 1; - - for (size_t index = 1; index < argc; ++index) - { - std::string index_path = argv[index]; - - if (index_path == "/Ver" || - index_path == "/Version") - { - std::cout << "Usage: btb \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 Technologies, all rights reserved.\n"; - - return 0; - } - else if (index_path == "/?" || - index_path == "/Help") - { - std::cout << "btb: Build a JSON file: btb .json\n"; - std::cout << "btb: Build a TOML file: btb .toml\n"; - - return 0; - } - - std::thread job_build_thread([](std::string index_path) -> void { - IManifestBuilder* builder = nullptr; - - if (index_path.ends_with(".json")) - { - builder = new JSONManifestBuilder(); - } - else if (index_path.ends_with(".toml")) - { - builder = new TOMLManifestBuilder(); - } - else - { - cFailed = true; - return; - } - - std::cout << "btb: building: " << index_path << std::endl; - - if (builder && !builder->Build(index_path.size(), index_path.c_str())) - { - cFailed = true; - } - - delete builder; - - --cJobIndex; - }, - index_path); - - job_build_thread.detach(); - } - - // wait for completion of all jobs. - while (cJobIndex) - { - if (cFailed) - { - std::cout << "btb: build failed: " << errno << "." << std::endl; - return EXIT_FAILURE; - } - } - - return cFailed ? EXIT_FAILURE : EXIT_SUCCESS; -} diff --git a/cli/CliApp.cxx b/cli/CliApp.cxx new file mode 100644 index 0000000..c2f9aad --- /dev/null +++ b/cli/CliApp.cxx @@ -0,0 +1,91 @@ +// ============================================================= // +// btb +// Copyright ZKA Technologies. +// ============================================================= // + +#include +#include +#include +#include +#include +#include +#include + +static int cJobIndex = 0; +static bool cFailed = false; + +int main(int argc, char** argv) +{ + cJobIndex = argc - 1; + + for (size_t index = 1; index < argc; ++index) + { + std::string index_path = argv[index]; + + if (index_path == "/Ver" || + index_path == "/Version") + { + std::cout << "Usage: btb \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 Technologies, all rights reserved.\n"; + + return 0; + } + else if (index_path == "/?" || + index_path == "/Help") + { + std::cout << "btb: Build a JSON file: btb .json\n"; + std::cout << "btb: Build a TOML file: btb .toml\n"; + + return 0; + } + + std::thread job_build_thread([](std::string index_path) -> void { + IManifestBuilder* builder = nullptr; + + const auto cJsonExt = ".json"; + + if (index_path.ends_with(cJsonExt)) + { + builder = new JSONManifestBuilder(); + } + else + { + cFailed = true; + return; + } + + std::cout << "btb: building: " << index_path << std::endl; + + if (builder && !builder->Build(index_path.size(), index_path.c_str())) + { + cFailed = true; + } + else if (!builder) + { + cFailed = true; + } + + delete builder; + + --cJobIndex; + }, + index_path); + + job_build_thread.detach(); + } + + // wait for completion of all jobs. + while (cJobIndex) + { + if (cFailed) + { + std::cout << "btb: build failed: " << errno << "." << std::endl; + return EXIT_FAILURE; + } + } + + return cFailed ? EXIT_FAILURE : EXIT_SUCCESS; +} -- cgit v1.2.3