Hide completed tasks by default

This commit is contained in:
augustin64 2023-07-12 22:00:57 +02:00
parent dd0a0db947
commit 722c88a1b2
3 changed files with 10 additions and 9 deletions

View File

@ -190,7 +190,7 @@ void get_task(int id, task_t* t) {
// t->id will be (-1) if not found // t->id will be (-1) if not found
} }
int list_tasks() { int list_tasks(bool show_completed) {
sqlite3* db = get_db(); sqlite3* db = get_db();
sqlite3_stmt *stmt; sqlite3_stmt *stmt;
@ -211,12 +211,12 @@ int list_tasks() {
//* Warning: t just lives here (particularly t.text) //* Warning: t just lives here (particularly t.text)
if (t.done) { if (t.done) {
printf(BOLD GREEN); if (show_completed) {
} else { printf(BOLD GREEN "[%d]" RESET " %s\n", t.id, t.text);
printf(BOLD YELLOW); }
} else {
printf(BOLD YELLOW "[%d]" RESET " %s\n", t.id, t.text);
} }
printf("[%d]" RESET " %s\n", t.id, t.text);
} }
sqlite3_finalize(stmt); sqlite3_finalize(stmt);

View File

@ -38,7 +38,7 @@ void get_task(int id, task_t* t);
/* /*
Liste les tâches dans un format prédéfini 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é Renvoie un identifiant de tâche encore non utilisé

View File

@ -10,11 +10,12 @@
void help(char* name) { void help(char* name) {
printf(BLUE "\t-- TaKl " VERSION " --\n" RESET); 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 <task> [date]\n"); printf("\tadd <task> [date]\n");
printf("\tFormat de la date:\n"); printf("\tFormat de la date:\n");
printf("\t\tRelatif: min+%%d, h+%%d, j+%%d\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 <id1> <id2> ...\n"); printf("\tinfo <id1> <id2> ...\n");
printf("\tdone <id1> <id2> ...\n"); printf("\tdone <id1> <id2> ...\n");
printf("\trm <id1> <id2> ...\n"); printf("\trm <id1> <id2> ...\n");
@ -187,7 +188,7 @@ int main(int argc, char* argv[]) {
if (!strcmp(argv[1], "add")) { if (!strcmp(argv[1], "add")) {
return add(argc, argv); return add(argc, argv);
} else if (!strcmp(argv[1], "list")) { } else if (!strcmp(argv[1], "list")) {
return list_tasks(); return list_tasks(argc > 2 && !strcmp(argv[2], "-a"));
} else if (!strcmp(argv[1], "info")) { } else if (!strcmp(argv[1], "info")) {
return info(argc, argv); return info(argc, argv);
} else if (!strcmp(argv[1], "done")) { } else if (!strcmp(argv[1], "done")) {