aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
blob: d64de1af7777d21b84c44e3991c798ce41791aeb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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;
}