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 heading "Today";
45 (string_of_task_desc desc) (string_of_taskid id)
49 let rows = PGSQL(dbh) "select todo.taskid, todo.deadline, todo.estimate,
52 where todo.taskid = tasks.id
53 order by todo.deadline" in
54 if rows <> [] then heading "To-do list";
56 fun (id, deadline, estimate, desc) ->
58 if Time.equal (Time.midnight ()) (Calendar.to_time deadline) then
59 Printer.Calendar.sprint "%F" deadline
61 Printer.Calendar.to_string deadline in
65 | Some period -> string_of_estimate period ^ " " in
66 printf " %s %s%s %s%s\n"
67 deadline estimate (string_of_task_desc desc)
68 (string_of_taskid id) (tags_of_task dbh id)
71 let rows = PGSQL(dbh) "
72 select tasks.id, tasks.description
74 where not exists (select 1 from imminent where taskid = tasks.id)
75 and not exists (select 1 from todo where taskid = tasks.id)
76 and not exists (select 1 from ideas where taskid = tasks.id)
77 and not exists (select 1 from retired where taskid = tasks.id)
78 order by tasks.description" in
79 if rows <> [] then heading "Unsorted (use 'todo move' to move these)";
83 (string_of_task_desc desc) (string_of_taskid id)
87 let rows = PGSQL(dbh) "select ideas.taskid, tasks.description
89 where ideas.taskid = tasks.id
90 order by tasks.description" in
91 if rows <> [] then heading "Ideas";
95 (string_of_task_desc desc) (string_of_taskid id)
100 if show_retired then (
101 let rows = PGSQL(dbh) "select retired.taskid, tasks.description
103 where retired.taskid = tasks.id
104 order by tasks.description" in
105 if rows <> [] then heading "Retired";
109 (string_of_task_desc desc) (string_of_taskid id)
110 (tags_of_task dbh id)