From 62294eb66c1ef061002165c692266d5d5f7f1cd1 Mon Sep 17 00:00:00 2001 From: dam Date: Sun, 2 Oct 2022 00:22:53 +0000 Subject: Fixed argument checking on some argument driven actions. --- main.c | 8 ++++++-- readme.md | 11 ++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/main.c b/main.c index 8817d6d..8e6cfbc 100644 --- a/main.c +++ b/main.c @@ -1,6 +1,8 @@ // Compilation command: // - release: gcc main.c -Wall -Werror -pedantic -O2 -m64 -lncursesw -o ttt // - debug : gcc main.c -Wall -Werror -pedantic -g3 -m64 -lncursesw -o ttt -D DEBUG +// Usage hints: +// - To changes app data path change the environment variable HOME (USERPROFILE for windows users). #include @@ -996,8 +998,9 @@ int main(int argc, char *argv[]) { action = "--icsv"; do_action = strncmp(argv[idx], action, strlen(action)+1) == 0; if (do_action) { - if (argc < idx+1) { + if (idx+1 >= argc) { fprintf(stdout, "Missing CSV file path to import.\n"); + return EXIT_FAILURE; } load_database(&database, db_file_path); import_from_csv(&database, argv[idx+1]); @@ -1009,8 +1012,9 @@ int main(int argc, char *argv[]) { action = "--ecsv"; do_action = strncmp(argv[idx], action, strlen(action)+1) == 0; if (do_action) { - if (argc < idx+1) { + if (idx+1 >= argc) { fprintf(stdout, "Missing CSV file path to export.\n"); + return EXIT_FAILURE; } load_database(&database, db_file_path); export_to_csv(&database, argv[idx+1]); diff --git a/readme.md b/readme.md index 9013deb..b025f35 100644 --- a/readme.md +++ b/readme.md @@ -39,18 +39,19 @@ Task Time Tracker - [x] At startup, check for required files and create them if not present. - [x] Allow to archive task using keys: `a` and `A`; - [x] By default, store files on `~/.config/task_time_tracker/` or `~/.local/share/task_time_tracker` and allow to store elsewhere if passed by argument `--config`. -- [ ] Allow usage of `ttt: ./ttt --dpath ./` to change the app folder; +- [x] Allow usage of `ttt: ./ttt --dpath ./` to change the app folder: To changes app data path change the environment variable HOME (USERPROFILE for windows users). +- [ ] Clone (replicate) task; If task is active, mark newly created task as inactive; - [ ] Confirm delete_task operation. - [ ] Change task order (using task_t tmp_task + memcpy); -- [ ] Create task using keys: `c` and `C`; -- [ ] Delete task using keys: `d` and `D`; -- [ ] Change task name using keys: `F2`; - [ ] Add/remove time using keys: `F3`; - [ ] Add/remove time for any day of week; -- [ ] Clone (replicate) task using keys: `r` and `R`; If task is active, mark newly created task as inactive; - [ ] Implement logs as described above. - [ ] Go over all `TODO` items; - [ ] Rethink keys; + - [ ] Create task using keys: `c` and `C`; + - [ ] Delete task using keys: `d` and `D`; + - [ ] Change task name using keys: `F2`; + - [ ] Clone task using keys: `r` and `R`; - [ ] Cleanup `draw_tui`: - Selected and active tasks should be drawn after everything else. - Try printing each row; -- cgit v1.2.3