diff --git a/src/include/config.h b/src/include/config.h index 489e610..32b9000 100644 --- a/src/include/config.h +++ b/src/include/config.h @@ -1,7 +1,7 @@ #ifndef DEF_CONFIG_H #define DEF_CONFIG_H -#define VERSION "1.0.1" +#define VERSION "1.0.2" // By default, $HOME/.config/takl.sqlite3 is used. You can change this behaviour here //#define DB_FILE "takl.sqlite3" diff --git a/src/main.c b/src/main.c index b7802c7..0c45429 100644 --- a/src/main.c +++ b/src/main.c @@ -10,15 +10,17 @@ void help(char* name) { printf(BLUE "\t-- TaKl " VERSION " --\n" RESET); - printf("Utilisation: %s ( list | add | info | rm | done )\n", name); + printf("Utilisation: %s ( list | add | reschedule | info | rm | done )\n", name); printf("\tlist [-a:voir les tâches complétées]\n"); printf("\tadd [date]\n"); - printf("\tFormat de la date:\n"); - printf("\t\tRelatif: min+%%d, h+%%d, j+%%d\n"); - printf("\t\tAbsolu: dd/mm (pas de changement d'année pour l'instant)\n"); + printf("\treschedule [date]\n"); printf("\tinfo ...\n"); printf("\tdone ...\n"); printf("\trm ...\n"); + + printf("\nFormat des dates:\n"); + printf("\tRelatif: min+%%d, h+%%d, j+%%d\n"); + printf("\tAbsolu: dd/mm (pas de changement d'année pour l'instant)\n"); } @@ -98,6 +100,41 @@ int add(int argc, char* argv[]) { return 0; } +int reschedule(int argc, char* argv[]) { + if (argc < 3) { + printf(BOLD YELLOW "Argument manquant\n" RESET); + help(argv[0]); + return 1; + } + + int id = strtol(argv[2], NULL, 10); + + task_t t; + t.id = -1; + get_task(id, &t); + + if (t.id == -1) { + printf(YELLOW "Tâche " BOLD "[%d]" RESET YELLOW " inexistante. Vérifiez que l'identifiant est bien correct\n" RESET, id); + return 1; + } + + time_t due_to = parseDateTime(argv[3]); + + if (due_to == -1) { + printf(RED "Échéance invalide, impossible de reprogrammer la tâche.\n" RESET); + return 1; + } + + t.due_to = due_to; + + if (update_task(t) != 0) { + printf("Erreur lors de la modification de la tâche\n"); + return 1; + } + + return 0; +} + int list_tasks(bool show_completed) { task_list_t* tasks = get_task_list(show_completed); print_task_list(tasks, show_completed); // show_completed: true would work as all the tasks are not loaded if false @@ -195,6 +232,8 @@ int main(int argc, char* argv[]) { if (!strcmp(argv[1], "add")) { return add(argc, argv); + } else if (!strcmp(argv[1], "reschedule")) { + return reschedule(argc, argv); } else if (!strcmp(argv[1], "list")) { return list_tasks(argc > 2 && !strcmp(argv[2], "-a")); } else if (!strcmp(argv[1], "info")) {