summaryrefslogtreecommitdiffhomepage
path: root/cli
diff options
context:
space:
mode:
Diffstat (limited to 'cli')
-rw-r--r--cli/AppMain.cxx69
-rw-r--r--cli/BuilderJSON.cxx62
2 files changed, 69 insertions, 62 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;
+}
diff --git a/cli/BuilderJSON.cxx b/cli/BuilderJSON.cxx
deleted file mode 100644
index cffbe45..0000000
--- a/cli/BuilderJSON.cxx
+++ /dev/null
@@ -1,62 +0,0 @@
-#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;
-}