aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile26
-rw-r--r--src/main.c44
2 files changed, 70 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..6dd9909
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,26 @@
+# Compiler options
+CC=gcc
+CFLAGS=-std=c17 -Wall -Werror -g
+
+# Directory paths
+src=src
+bin=bin
+
+# Directives
+.PHONY: build
+build: $(bin)/ctodo
+
+.PHONY: clean
+clean:
+ -rm -r $(bin) $(obj)
+
+# Build executable
+$(bin)/ctodo: $(bin) $(src)/main.c
+ $(CC) $(CFLAGS) -o $@ $(filter-out $<,$^)
+
+# Make bin directory
+$(bin):
+ mkdir $@
+
+
+
diff --git a/src/main.c b/src/main.c
new file mode 100644
index 0000000..d64de1a
--- /dev/null
+++ b/src/main.c
@@ -0,0 +1,44 @@
+#include <stdbool.h> // for booleans
+#include <stdio.h> // for input/output
+#include <stdlib.h> // for STD macros
+#include <getopt.h> // for getopt
+
+void print_args(int argc, char* argv[]) {
+ printf("There are %i arguments\n",argc);
+ printf("Those arguments are:\n");
+ for (int i=0; i<argc; ++i) {
+ printf("argv[%i]: %s", i, argv[i]);
+ }
+}
+
+void new_todo(int argc, char** argv) {
+ printf("CREATE: ");
+ // just in case not using quotes
+ for (int i=2; i<argc; ++i) printf("%s ",argv[i]);
+ printf("\n");
+}
+
+void print_version() {
+ printf("todoc version 0.0.1\n");
+}
+
+int main(int argc, char* argv[]) {
+ char* valid_opts = "cv";
+ int opt;
+
+ while ((opt = getopt(argc, argv, valid_opts)) != -1) {
+ switch(opt) {
+ case 'c':
+ new_todo(argc,argv);
+ break;
+ case 'v':
+ print_version();
+ break;
+ default:
+ fprintf(stderr, "Usage: %s [%s] <heading>\n", argv[0], valid_opts);
+ exit(EXIT_FAILURE);
+ }
+ }
+
+ return 0;
+}