1 (* Implement 'move' subcommand. *)
10 (* The form of the command is one of:
12 * move ID [todo|task] deadline
17 let cmd_move dbh anon_params =
19 match anon_params with
20 | id :: rest -> Int32.of_string id, rest
21 | _ -> error "incorrect parameters to 'move' subcommand" in
23 match anon_params with
24 | ["today"|"imminent"] -> `Today
25 | ["todo"|"task"; deadline] ->
26 `Todo (Printer.Calendar.from_string deadline)
27 | ["idea"|"ideas"] -> `Ideas
28 | ["retire"|"retired"] -> `Retired
29 | ["none"|"unsorted"] -> `Unsorted
30 | _ -> error "incorrect destination for 'move' subcommand" in
32 PGOCaml.begin_work dbh;
34 (* Remove it from any other table. *)
35 PGSQL(dbh) "delete from imminent where taskid = $id";
36 PGSQL(dbh) "delete from todo where taskid = $id";
37 PGSQL(dbh) "delete from ideas where taskid = $id";
38 PGSQL(dbh) "delete from retired where taskid = $id";
40 (* Add it to the destination table. *)
43 PGSQL(dbh) "insert into imminent (taskid) values ($id)"
45 PGSQL(dbh) "insert into todo (taskid, deadline) values ($id, $deadline)"
47 PGSQL(dbh) "insert into ideas (taskid) values ($id)"
49 PGSQL(dbh) "insert into retired (taskid) values ($id)"
51 () (* Nothing - unsorted items are not present in any table. *)