todo-jsonl 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/todo.rb +13 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 889bafbe16e82bf4bc1d64a7cc4991a582693677c02a1a6ace65bdd04f20f4b6
|
4
|
+
data.tar.gz: 67def741aa050ac753c55af39488712aa3aed696f17c28366020233a59673810
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5de24eee9c08a01b1abfe1315bbc75444d0d7fa26e0f3c6c99f25911104ec5b3d428e4ae13c23cb3f7d6b931c6b059759b870b65af33ff795786676545813e2c
|
7
|
+
data.tar.gz: 4b10d821af4c52d466f621cc77961551556f915f063032b5e7525c8f5d3fff84b838d1564eeabf899c1480e64235654d1ca669922552ddb53bc4be6941033aab
|
data/bin/todo.rb
CHANGED
@@ -74,11 +74,8 @@ QUERIES = {
|
|
74
74
|
}
|
75
75
|
|
76
76
|
TODAY = DateTime.now
|
77
|
-
|
78
|
-
|
79
|
-
(2..6).each do |day|
|
80
|
-
DUE_DATE_DAYS.push((TODAY.to_date + day).strftime('%A').downcase)
|
81
|
-
end
|
77
|
+
DUE_DATE_DAYS = (0..6).map do |day| (TODAY.to_date + day).strftime('%A').downcase end
|
78
|
+
DUE_DATE_DAYS_SIMPLE = ['today', 'tomorrow']
|
82
79
|
|
83
80
|
PRIORITY_FLAG = '*'
|
84
81
|
|
@@ -195,7 +192,12 @@ end
|
|
195
192
|
|
196
193
|
def due_date(item, date = '')
|
197
194
|
tasks = load_tasks(item)
|
198
|
-
|
195
|
+
day_index = DUE_DATE_DAYS.index(date.to_s.downcase) || DUE_DATE_DAYS_SIMPLE.index(date.to_s.downcase)
|
196
|
+
if day_index
|
197
|
+
tasks[item][:due] = (TODAY.to_date + day_index).strftime(DATE_FORMAT)
|
198
|
+
else
|
199
|
+
tasks[item][:due] = date.nil? || date.empty? ? nil : Date.parse(date).strftime(DATE_FORMAT)
|
200
|
+
end
|
199
201
|
tasks[item][:modified] = Time.now.strftime(DATE_FORMAT)
|
200
202
|
write_tasks(tasks)
|
201
203
|
list(tasks)
|
@@ -229,7 +231,7 @@ def list(tasks = nil, patterns = nil)
|
|
229
231
|
if date_diff < 0
|
230
232
|
due_date = colorize("(#{date_diff.abs}d overdue)", :red)
|
231
233
|
elsif date_diff == 0 || date_diff == 1
|
232
|
-
due_date = colorize("(#{
|
234
|
+
due_date = colorize("(#{DUE_DATE_DAYS_SIMPLE[date_diff]})", :yellow)
|
233
235
|
else
|
234
236
|
due_date = colorize("(#{DUE_DATE_DAYS[date_diff] || task[:due]})", :magenta) if date_diff > 1
|
235
237
|
end
|
@@ -291,12 +293,16 @@ def read(arguments)
|
|
291
293
|
raise action + ' command requires at least one parameter' if args.nil? || args.empty?
|
292
294
|
add(args.join(' '))
|
293
295
|
when 'start'
|
296
|
+
raise action + ' command can receive only one task number' if args.length > 1
|
294
297
|
args.length == 1 ? change_state(args.first.to_i, 'started') : list(nil, [':started'])
|
295
298
|
when 'done'
|
299
|
+
raise action + ' command can receive only one task number' if args.length > 1
|
296
300
|
args.length == 1 ? change_state(args.first.to_i, 'done') : list(nil, [':done'])
|
297
301
|
when 'block'
|
302
|
+
raise action + ' command can receive only one task number' if args.length > 1
|
298
303
|
args.length == 1 ? change_state(args.first.to_i, 'blocked') : list(nil, [':blocked'])
|
299
304
|
when 'reset'
|
305
|
+
raise action + ' command can receive only one task number' if args.length > 1
|
300
306
|
args.length == 1 ? change_state(args.first.to_i, 'new') : list(nil, [':new'])
|
301
307
|
when 'prio'
|
302
308
|
raise action + ' command requires exactly one parameter' if args.length != 1
|