X-Git-Url: https://git.danieliu.xyz/?p=taskasaur.git;a=blobdiff_plain;f=main.c;h=6295b35d9bc722ffbdb48bcd6a6c73ce8c249f5b;hp=d57ec4d8b33b26a543c42d46f38e460d568ff8a3;hb=6afa85b8f5d9a77abaab11d47d7b8ab93f40d95d;hpb=4d4eab198ec016ec7c39cecf8b472ff3046fd965 diff --git a/main.c b/main.c index d57ec4d..6295b35 100644 --- a/main.c +++ b/main.c @@ -7,9 +7,13 @@ void winch_handler(int sig); WINDOW* create_list_win(int height, int width, int y, int x); +#include "config.h" + int main(int argc, char** argv) { + int flag; + FILE* board_file; int height, width; int x, y; int ch; @@ -17,6 +21,42 @@ main(int argc, char** argv) signal(SIGWINCH, winch_handler); + // read command line args + flag = getopt(argc, argv, "o:n::"); + switch (flag) { + case 'o': + + // read from task file (might need to check for read and write permissions) + board_file = fopen(optarg, "r"); + if (!board_file) { + printf("%s does not exist\n", optarg); + return 1; + } + break; + + case 'n': + /* ; */ + /* char to_create[]; */ + /* to_create = (optarg == 0) ? default_board : optarg; */ + + // make sure file does not exist + // however, it maybe be possible that an different error has occured (besides the file not existing) + if (access(optarg, F_OK) == 0) { + printf("%s already exists\n", optarg); + return 1; + } + /* printf("Successfully created %s\n", to_create); */ + break; + + case -1: + case '?': + printf("Help string\n"); + return 2; + + } + + return 0; + // start ncurses initscr(); cbreak(); @@ -34,9 +74,9 @@ main(int argc, char** argv) todo_win = create_list_win(20, 20, 5, 5); move(y,x); - while ((ch = getch()) != 113) { + while ((ch = getch()) != 113) { // while not q - //ofc the first thing we need is vim keys + // ofc the first thing we need is vim keys switch (ch) { case 104: // h x -= 1;