summaryrefslogtreecommitdiff
path: root/core.c
diff options
context:
space:
mode:
Diffstat (limited to 'core.c')
-rw-r--r--core.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/core.c b/core.c
index aa3a071..00539a7 100644
--- a/core.c
+++ b/core.c
@@ -2,7 +2,37 @@
#include <stdlib.h>
#include <stdio.h>
+#include <string.h>
+
+void gitrolex_parseArgs(struct State_t *s, int argc, const char *argv[]) {
+ const char *task;
+ if(argc < 2) {
+ s->task = ERROR;
+ return;
+ }
+ task = argv[1];
+ if(!strcmp(task, "status")) {
+ s->task = STATUS;
+ }
+ else if(!strcmp(task, "export")) {
+ s->task = EXPORT;
+ }
+ else if(!strcmp(task, "track")) {
+ // if we're tracking time,
+ // we need a branch name stored
+ // in the args
+ if(argc < 3) {
+ s->task = ERROR;
+ return;
+ }
+ s->task = TRACK;
+ strcpy(s->taskArgs, argv[2]);
+ }
+}
+
int gitrolex_core(int argc, const char* argv[]) {
+ struct State_t state;
+ gitrolex_parseArgs(&state, argc, argv);
printf("Usage ./gitrolex status | export | track <branch-name>\n");
}