diff --git a/src/db.c b/src/db.c index baa8dae..7ccdb1f 100644 --- a/src/db.c +++ b/src/db.c @@ -190,7 +190,7 @@ void get_task(int id, task_t* t) { // t->id will be (-1) if not found } -int list_tasks() { +int list_tasks(bool show_completed) { sqlite3* db = get_db(); sqlite3_stmt *stmt; @@ -211,12 +211,12 @@ int list_tasks() { //* Warning: t just lives here (particularly t.text) if (t.done) { - printf(BOLD GREEN); + if (show_completed) { + printf(BOLD GREEN "[%d]" RESET " %s\n", t.id, t.text); + } } else { - printf(BOLD YELLOW); + printf(BOLD YELLOW "[%d]" RESET " %s\n", t.id, t.text); } - - printf("[%d]" RESET " %s\n", t.id, t.text); } sqlite3_finalize(stmt); diff --git a/src/include/db.h b/src/include/db.h index 6ec3702..0d2e2cc 100644 --- a/src/include/db.h +++ b/src/include/db.h @@ -38,7 +38,7 @@ void get_task(int id, task_t* t); /* Liste les tâches dans un format prédéfini */ -int list_tasks(); +int list_tasks(bool show_completed); /* Renvoie un identifiant de tâche encore non utilisé diff --git a/src/main.c b/src/main.c index 6abb2db..5132eb7 100644 --- a/src/main.c +++ b/src/main.c @@ -10,11 +10,12 @@ void help(char* name) { printf(BLUE "\t-- TaKl " VERSION " --\n" RESET); - printf("Utilisation: %s ( list | info | add | rm | done )\n", name); + printf("Utilisation: %s ( list | add | 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("\t\tAbsolu: dd/mm (pas de changement d'année pour l'instant)\n"); printf("\tinfo ...\n"); printf("\tdone ...\n"); printf("\trm ...\n"); @@ -187,7 +188,7 @@ int main(int argc, char* argv[]) { if (!strcmp(argv[1], "add")) { return add(argc, argv); } else if (!strcmp(argv[1], "list")) { - return list_tasks(); + return list_tasks(argc > 2 && !strcmp(argv[2], "-a")); } else if (!strcmp(argv[1], "info")) { return info(argc, argv); } else if (!strcmp(argv[1], "done")) {