taiga/src/main.c

41 lines
1.1 KiB
C
Raw Normal View History

2026-03-01 20:48:09 +09:00
#include <taiga.h>
2026-03-01 03:20:18 +09:00
2026-03-02 17:32:20 +09:00
int main(int argc, char** argv) {
int i;
char* action = NULL;
int target_argc = 0;
2026-03-01 20:48:09 +09:00
char** target_argv = malloc(sizeof(*target_argv));
2026-03-02 17:32:20 +09:00
target_argv[0] = NULL;
2026-03-01 20:48:09 +09:00
2026-03-10 03:28:25 +09:00
fprintf(stderr, "Taiga, static website generator - run `%s help' for help\n\n", argv[0]);
2026-03-01 20:54:30 +09:00
2026-03-02 17:32:20 +09:00
for(i = 1; i < argc; i++) {
if(argv[i][0] == '-') {
2026-03-08 22:32:33 +09:00
if(action != NULL) continue;
2026-03-02 17:32:20 +09:00
} else {
2026-03-08 22:32:33 +09:00
if(action != NULL) continue;
2026-03-01 20:48:09 +09:00
action = argv[i];
2026-03-02 17:32:20 +09:00
2026-03-01 20:48:09 +09:00
free(target_argv);
target_argc = argc - i - 1;
target_argv = &argv[i + 1];
}
}
2026-03-08 22:32:33 +09:00
if(action == NULL) action = "site";
2026-03-01 20:54:30 +09:00
2026-03-02 17:32:20 +09:00
if(strcmp(action, "site") == 0) {
2026-03-01 20:54:30 +09:00
return action_site(target_argc, target_argv);
2026-03-02 17:32:20 +09:00
} else if(strcmp(action, "help") == 0) {
2026-03-01 22:43:41 +09:00
return action_help(target_argc, target_argv);
2026-03-02 17:32:20 +09:00
} else if(strcmp(action, "seed") == 0) {
2026-03-01 22:43:41 +09:00
return action_seed(target_argc, target_argv);
2026-03-10 03:28:25 +09:00
} else if(strcmp(action, "markdown") == 0) {
return action_markdown(target_argc, target_argv);
2026-03-10 03:59:18 +09:00
} else if(strcmp(action, "markdown-dir") == 0) {
return action_markdown_dir(target_argc, target_argv);
2026-03-01 20:54:30 +09:00
}
fprintf(stderr, "Unknown action\n");
return 1;
2026-03-01 03:20:18 +09:00
}