aboutsummaryrefslogtreecommitdiff
path: root/src/Main.c
diff options
context:
space:
mode:
authorfrosty <gabriel@bwaaa.monster>2026-09-16 16:32:06 -0400
committerfrosty <gabriel@bwaaa.monster>2026-09-16 16:32:06 -0400
commit4c8d764d171ec77ff626cec273c44ec7e7a995fc (patch)
treedc36193e611ece53c8f7e74d1dea71f8d9e7004e /src/Main.c
downloadyapssg-master.tar.gz
init: initHEADmaster
Diffstat (limited to 'src/Main.c')
-rw-r--r--src/Main.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/Main.c b/src/Main.c
new file mode 100644
index 0000000..b7c77f1
--- /dev/null
+++ b/src/Main.c
@@ -0,0 +1,52 @@
+#include "Cli/Cli.h"
+#include "FileProcessor/FileProcessor.h"
+#include "Logger/Logger.h"
+#include "Path/Path.h"
+
+#include <libxml/parser.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+static int run(int argc, char **argv) {
+ CliOptions options;
+ CliParseResult parse_result;
+ char *automatic_output = NULL;
+ const char *output_path;
+ int result;
+
+ parse_result = cli_parse(argc, argv, &options);
+ if (parse_result != CLI_PARSE_OK) {
+ return parse_result == CLI_PARSE_ERROR ? EXIT_FAILURE : EXIT_SUCCESS;
+ }
+
+ logger_set_level(options.log_level);
+
+ output_path = options.output_path;
+ if (output_path == NULL) {
+ automatic_output = path_make_default_output(options.input_path);
+ if (automatic_output == NULL) {
+ logger_error("unable to allocate output path");
+ return EXIT_FAILURE;
+ }
+ output_path = automatic_output;
+ }
+
+ if (options.input_type == INPUT_TYPE_DIRECTORY) {
+ result = process_directory(options.input_path, output_path,
+ options.overwrite_output);
+ } else {
+ result = process_file(options.input_path, output_path);
+ }
+
+ free(automatic_output);
+ return result == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
+}
+
+int main(int argc, char **argv) {
+ int result;
+
+ xmlInitParser();
+ result = run(argc, argv);
+ xmlCleanupParser();
+ return result;
+}