1 (* Implement 'list' subcommand. *)
11 let tags_of_task dbh id =
12 let rows = PGSQL(dbh) "select tags.name, tags.colour
14 where tags_tasks.taskid = $id
15 and tags_tasks.tagid = tags.id
16 order by tags.name" in
23 string_of_tag name colour
26 let cmd_list dbh anon_params list_retired list_all =
27 if anon_params <> [] then
28 error "extra parameters to 'list' subcommand";
30 let show_unretired, show_retired =
31 match list_retired, list_all with
32 | _, true -> true, true
33 | false, false -> true, false
34 | true, false -> false, true in
36 if show_unretired then (
37 let rows = PGSQL(dbh) "select imminent.taskid, tasks.description
39 where imminent.taskid = tasks.id
40 order by tasks.description" in
41 if rows <> [] then printf "Today:\n";
44 printf " %s #%ld%s\n" desc id (tags_of_task dbh id)
47 let rows = PGSQL(dbh) "select todo.taskid, todo.deadline, todo.estimate,
50 where todo.taskid = tasks.id
51 order by todo.deadline" in
52 if rows <> [] then printf "To-do list:\n";
54 fun (id, deadline, estimate, desc) ->
56 if Time.equal (Time.midnight ()) (Calendar.to_time deadline) then
57 Printer.Calendar.sprint "%F" deadline
59 Printer.Calendar.to_string deadline in
63 | Some period -> string_of_estimate period ^ " " in
64 printf " %s %s%s #%ld%s\n"
65 deadline estimate desc id (tags_of_task dbh id)
68 let rows = PGSQL(dbh) "
69 select tasks.id, tasks.description
71 where not exists (select 1 from imminent where taskid = tasks.id)
72 and not exists (select 1 from todo where taskid = tasks.id)
73 and not exists (select 1 from ideas where taskid = tasks.id)
74 and not exists (select 1 from retired where taskid = tasks.id)
75 order by tasks.description" in
76 if rows <> [] then printf "Unsorted (use 'todo move' to move these):\n";
79 printf " %s #%ld%s\n" desc id (tags_of_task dbh id)
82 let rows = PGSQL(dbh) "select ideas.taskid, tasks.description
84 where ideas.taskid = tasks.id
85 order by tasks.description" in
86 if rows <> [] then printf "Ideas:\n";
89 printf " %s #%ld%s\n" desc id (tags_of_task dbh id)
93 if show_retired then (
94 let rows = PGSQL(dbh) "select retired.taskid, tasks.description
96 where retired.taskid = tasks.id
97 order by tasks.description" in
98 if rows <> [] then printf "Retired:\n";
101 printf " %s #%ld%s\n" desc id (tags_of_task dbh id)