Skip to content

Commit 784f844

Browse files
authored
Merge pull request #144 from hackberrydev/obsolete-task
Obsolete task
2 parents 8715c3f + e2b647e commit 784f844

5 files changed

Lines changed: 15 additions & 5 deletions

File tree

src/plan/parser.janet

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,10 @@
5050
:task-begin
5151
{:main (* "- " :checkbox)
5252
:checkbox
53-
{:main (+ :checkbox-done :checkbox-pending)
53+
{:main (+ :checkbox-done :checkbox-pending :checkbox-obsolete)
5454
:checkbox-done (* (+ "[x]" "[X]") (constant :checked))
55-
:checkbox-pending (* "[ ]" (constant :open))}}
55+
:checkbox-pending (* "[ ]" (constant :open))
56+
:checkbox-obsolete(* "[~]" (constant :obsolete))}}
5657
:task-missed-on-date (* " (missed on " (constant :missed-on) :date ")")
5758
:task-body
5859
{:main (group (any :task-body-line))

src/plan/serializer.janet

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
(string "# " (plan :title)))
1010

1111
(defn- checkbox [task]
12-
(if (= (task :state) :checked) "[X]" "[ ]"))
12+
(case (task :state)
13+
:open "[ ]"
14+
:checked "[X]"
15+
:obsolete "[~]"))
1316

1417
(defn- serialize-event-title [event]
1518
(string "- " (event :title)))

src/task.janet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
(import ./date)
55

6-
(def states [:open :checked])
6+
(def states [:open :checked :obsolete])
77

88
(defn build-task [title state &opt body]
99
(default body @[])

test/plan/parser_test.janet

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
## 2020-07-31, Friday
2626
2727
- Talked to Mike & Molly
28-
- [x] #work - Review open pull requests
28+
- [X] #work - Review open pull requests
29+
- [~] #work - Review logs
2930
- [x] #work - Fix the flaky test
3031
```)
3132
(def parse-result (parse plan-string))
@@ -59,6 +60,9 @@
5960
(test (task :title) "#work - Review open pull requests")
6061
(test (task :state) :checked))
6162
(let [task ((day-2 :tasks) 1)]
63+
(test (task :title) "#work - Review logs")
64+
(test (task :state) :obsolete))
65+
(let [task ((day-2 :tasks) 2)]
6266
(test (task :title) "#work - Fix the flaky test")
6367
(test (task :state) :checked)))
6468

test/plan/serializer_test.janet

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
(day/build-day (d/date 2020 8 1)
1818
@[(event/build-event "Talked to Mike" @["- He has a new car"])]
1919
@[(task/build-task "Develop photos" :open)
20+
(task/build-task "Fix the lamp" :obsolete)
2021
(task/build-task "Pay bills" :checked @["- Electricity" "- Water"])
2122
(task/build-missed-task "Organize photos" (d/date 2020 7 20))])
2223
(day/build-day (d/date 2020 7 31)
@@ -40,6 +41,7 @@
4041
- Talked to Mike
4142
- He has a new car
4243
- [ ] Develop photos
44+
- [~] Fix the lamp
4345
- [X] Pay bills
4446
- Electricity
4547
- Water

0 commit comments

Comments
 (0)