summaryrefslogtreecommitdiff
path: root/cmd/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/main.c')
-rw-r--r--cmd/main.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/cmd/main.c b/cmd/main.c
new file mode 100644
index 0000000..41014f3
--- /dev/null
+++ b/cmd/main.c
@@ -0,0 +1,44 @@
+/* This file is a part of todo
+ *
+ * Copyright (C) 2021 Robby Zambito
+ *
+ * todo is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * todo is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "todo.h"
+
+#define STREQ(a, b) (strcmp(a, b) == 0)
+
+int main(int argc, char **argv) {
+ if (argc == 1 || STREQ("list", argv[1])) {
+ todo_list();
+ } else if (STREQ("add", argv[1])) {
+ todo_add(argc - 2, argv + 2);
+ } else if (STREQ("rm", argv[1])) {
+ todo_rm(argc - 2, argv + 2);
+ } else if (STREQ("done", argv[1])) {
+ todo_done(argc - 2, argv + 2);
+ } else if (STREQ("raw", argv[1])) {
+ todo_raw(argc - 2, argv + 2);
+ } else if (STREQ("sort", argv[1])) {
+ todo_sort();
+ } else {
+ todo_help();
+ }
+
+ return EXIT_SUCCESS;
+}