diff options
| author | Amlal <amlal@zka.com> | 2024-09-20 15:50:58 +0200 |
|---|---|---|
| committer | Amlal <amlal@zka.com> | 2024-09-20 15:50:58 +0200 |
| commit | e59596db6f3e92098fdc0c3715f0a41cd10a0333 (patch) | |
| tree | d2d126ce86f452add889df780897a2242de73e0e /cli/AppMain.cxx | |
| parent | 602a5b177636ed55e950b239eedfc0d3217b97e1 (diff) | |
Add new contract for buildable manifests.
Signed-off-by: Amlal <amlal@zka.com>
Diffstat (limited to 'cli/AppMain.cxx')
| -rw-r--r-- | cli/AppMain.cxx | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/cli/AppMain.cxx b/cli/AppMain.cxx new file mode 100644 index 0000000..e52daa3 --- /dev/null +++ b/cli/AppMain.cxx @@ -0,0 +1,69 @@ +#include "IManifestBuilder.hxx" +#include <JSONManifestBuilder.hxx> +#include <cstdio> +#include <cstddef> +#include <string> +#include <iostream> +#include <thread> + +int cJobIndex = 0; +bool cFailed = false; + +static IManifestBuilder* cBuilder = new JSONManifestBuilder(); + +int main(int argc, char** argv) +{ + cJobIndex = argc - 1; + + for (size_t index = 1; index < argc; ++index) + { + std::string index_json = argv[index]; + + if (index_json == "/Ver" || + index_json == "/Version") + { + std::cout << "Usage: btb <file>\n"; + std::cout << "Filename is: " << argv[0] << "\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_json == "/?" || + index_json == "/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; + } + + std::thread job([](std::string index_json) -> void { + std::cout << "btb: Building " << index_json << std::endl; + + if (!cBuilder->Build(index_json.size(), index_json.c_str())) + { + std::string format = "btb "; + format += index_json; + + cFailed = true; + } + + --cJobIndex; + }, + index_json); + + job.detach(); + } + + // wait for completion of all jobs. + while (cJobIndex) + ; + + delete cBuilder; + + return cFailed ? 1 : 0; +} |
