diff options
| author | Amlal <amlal@zka.com> | 2024-09-08 21:27:22 +0200 |
|---|---|---|
| committer | Amlal <amlal@zka.com> | 2024-09-08 21:27:22 +0200 |
| commit | 602a5b177636ed55e950b239eedfc0d3217b97e1 (patch) | |
| tree | 310385b731b349a918de2b24a13f15cdf07e59fe /cli/BuilderJSON.cxx | |
| parent | b24daff9b2931a8152e6056a88b40823d6adcd78 (diff) | |
[src/ManifestBuilder.cxx] Almost detect ELF executables.
[cli/BuilderJSON.cxx] Improve code readiblity.
Signed-off-by: Amlal <amlal@zka.com>
Diffstat (limited to 'cli/BuilderJSON.cxx')
| -rw-r--r-- | cli/BuilderJSON.cxx | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/cli/BuilderJSON.cxx b/cli/BuilderJSON.cxx new file mode 100644 index 0000000..cffbe45 --- /dev/null +++ b/cli/BuilderJSON.cxx @@ -0,0 +1,62 @@ +#include <cstdio> +#include <manifest_builder.hxx> +#include <cstddef> +#include <string> +#include <iostream> +#include <thread> + +int cJobIndex = 0; +bool cFailed = false; + +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" || + index_json == "/?" || + index_json == "/Help") + { + std::cout << "btb: 🚀 Basic Tool for Building (JSON support).\n"; + std::cout << "btb: Brought to you by Amlal El Mahrouss.\n"; + std::cout << "btb: © ZKA Technologies, all rights reserved.\n"; + + if (index_json == "/?" || + index_json == "/Help") + std::cout << "btb: 🆘 run file: btb <json_path>.json\n"; + + return 0; + } + + std::thread job([](std::string index_json) -> void { + std::cout << "btb: " << index_json << std::endl; + + ManifestBuilder builder; + + if (!builder.buildJson(index_json.size(), index_json.c_str())) + { + std::string format = "btb "; + format += index_json; + + perror(format.c_str()); + + cFailed = true; + } + + --cJobIndex; + }, + index_json); + + job.detach(); + } + + // wait for completion of all jobs. + while (cJobIndex) + ; + + return cFailed ? 1 : 0; +} |
