todo-jsonl 0.1.24 → 0.1.25
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 +48 -56
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d47bb16f60f84f6c3e55951169bdb0871f915b7a6948844897fa8a150df05456
|
4
|
+
data.tar.gz: '09600be32199c25bc946036ee947290c7c77472d00933fee39c67d9bd2dc0649'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ae62a56b667ebcb55e661d1ac64cd4c2b62db7d7d4f106c79a034ca58264d4d7c3ea20a4d262e4386806baa88d472c88dcc5a6946c4d3ca8eb01bbc3d99363e
|
7
|
+
data.tar.gz: ede2f1f9f155ce5ff5acacdd784b030c01e11f14a4ef6d85e5223663dc3a0dea5a2ab8a3eac95f498808747fa9588723d1feef36828e4657ee23cd41736aa4e0
|
data/bin/todo.rb
CHANGED
@@ -155,7 +155,7 @@ class Todo
|
|
155
155
|
* list <regex> [regex...] list tasks (only active tasks by default)
|
156
156
|
* show <tasknumber> show all task details
|
157
157
|
* repl enter read-eval-print loop mode
|
158
|
-
* cleanup <regex> [regex...] cleanup completed tasks by
|
158
|
+
* cleanup <regex> [regex...] cleanup completed tasks by regex
|
159
159
|
* help this help screen
|
160
160
|
|
161
161
|
With list command the following pre-defined regex patterns can be also used:
|
@@ -201,9 +201,7 @@ class Todo
|
|
201
201
|
end
|
202
202
|
end
|
203
203
|
end
|
204
|
-
if item_to_check && !tasks.has_key?(item_to_check)
|
205
|
-
raise "#{item_to_check}: No such todo"
|
206
|
-
end
|
204
|
+
raise "#{item_to_check}: No such todo" if item_to_check && !tasks.has_key?(item_to_check)
|
207
205
|
tasks
|
208
206
|
end
|
209
207
|
|
@@ -237,69 +235,67 @@ class Todo
|
|
237
235
|
list
|
238
236
|
end
|
239
237
|
|
240
|
-
def
|
238
|
+
def update_task(item, post_action, update_function)
|
241
239
|
tasks = load_tasks(item)
|
242
|
-
tasks[item]
|
240
|
+
update_function.call(tasks[item])
|
243
241
|
tasks[item][:modified] = @today.strftime(DATE_FORMAT)
|
244
|
-
postprocess_tags(tasks[item])
|
245
242
|
write_tasks(tasks)
|
246
|
-
|
243
|
+
send(post_action, tasks) if post_action
|
244
|
+
end
|
245
|
+
|
246
|
+
def append(item, text = '')
|
247
|
+
update_task item, :list, lambda { |task|
|
248
|
+
task[:title] = [task[:title], text].join(' ')
|
249
|
+
postprocess_tags(task)
|
250
|
+
}
|
247
251
|
end
|
248
252
|
|
249
253
|
def rename(item, text)
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
write_tasks(tasks)
|
255
|
-
list(tasks)
|
254
|
+
update_task item, :list, lambda { |task|
|
255
|
+
task[:title] = text
|
256
|
+
postprocess_tags(task)
|
257
|
+
}
|
256
258
|
end
|
257
259
|
|
258
260
|
def delete(item)
|
259
261
|
tasks = load_tasks(item)
|
260
262
|
tasks.delete(item)
|
261
263
|
write_tasks(tasks)
|
262
|
-
list
|
264
|
+
list(tasks)
|
263
265
|
end
|
264
266
|
|
265
267
|
def change_state(item, state, note = nil)
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
write_tasks(tasks)
|
274
|
-
list(tasks)
|
268
|
+
update_task item, :list, lambda { |task|
|
269
|
+
task[:state] = state
|
270
|
+
if !note.nil? && !note.empty?
|
271
|
+
task[:note] ||= []
|
272
|
+
task[:note].push(note)
|
273
|
+
end
|
274
|
+
}
|
275
275
|
end
|
276
276
|
|
277
277
|
def set_priority(item, note = nil)
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
write_tasks(tasks)
|
287
|
-
list(tasks)
|
278
|
+
update_task item, :list, lambda { |task|
|
279
|
+
task[:priority] = !task[:priority]
|
280
|
+
task.delete(:priority) if !task[:priority]
|
281
|
+
if !note.nil? && !note.empty?
|
282
|
+
task[:note] ||= []
|
283
|
+
task[:note].push(note)
|
284
|
+
end
|
285
|
+
}
|
288
286
|
end
|
289
287
|
|
290
288
|
def due_date(item, date = '')
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
write_tasks(tasks)
|
296
|
-
list(tasks)
|
289
|
+
update_task item, :list, lambda { |task|
|
290
|
+
task[:due] = convert_due_date(date)
|
291
|
+
task.delete(:due) if task[:due].nil?
|
292
|
+
}
|
297
293
|
end
|
298
294
|
|
299
295
|
def list(tasks = nil, patterns = nil)
|
300
296
|
tasks = tasks || load_tasks
|
301
297
|
task_indent = [tasks.keys.max.to_s.size, 4].max
|
302
|
-
patterns = patterns.nil? || patterns.empty? ? [
|
298
|
+
patterns = patterns.nil? || patterns.empty? ? [':active'] : patterns
|
303
299
|
items = filter_tasks(tasks, patterns)
|
304
300
|
items = items.sort_by do |num, task|
|
305
301
|
[task[:priority] && task[:state] != 'done' ? 0 : 1, ORDER[task[:state] || 'default'], task[:due] || 'n/a', num]
|
@@ -330,24 +326,20 @@ class Todo
|
|
330
326
|
end
|
331
327
|
|
332
328
|
def add_note(item, text)
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
write_tasks(tasks)
|
338
|
-
show(item)
|
329
|
+
update_task item, :show, lambda { |task|
|
330
|
+
task[:note] ||= []
|
331
|
+
task[:note].push(text)
|
332
|
+
}
|
339
333
|
end
|
340
334
|
|
341
335
|
def delete_note(item)
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
write_tasks(tasks)
|
346
|
-
show(item)
|
336
|
+
update_task item, :show, lambda { |task|
|
337
|
+
task.delete(:note)
|
338
|
+
}
|
347
339
|
end
|
348
340
|
|
349
|
-
def show(item)
|
350
|
-
tasks = load_tasks(item)
|
341
|
+
def show(item, tasks = nil)
|
342
|
+
tasks = tasks || load_tasks(item)
|
351
343
|
tasks[item].each do |key, value|
|
352
344
|
val = value.kind_of?(Array) ? "\n" + value.join("\n") : value
|
353
345
|
puts "#{colorize(key.to_s.rjust(10, ' ') + ':', :cyan)} #{val}"
|
@@ -369,7 +361,7 @@ class Todo
|
|
369
361
|
|
370
362
|
def cleanup(patterns)
|
371
363
|
tasks = load_tasks
|
372
|
-
patterns = [
|
364
|
+
patterns = [':done'] + patterns.to_a
|
373
365
|
items = filter_tasks(tasks, patterns)
|
374
366
|
items.keys.each do |num| tasks.delete(num) end
|
375
367
|
write_tasks(tasks)
|
@@ -393,7 +385,7 @@ class Todo
|
|
393
385
|
"\e[#{COLOR_CODES[color]}m#{text}\e[0m"
|
394
386
|
end
|
395
387
|
|
396
|
-
def convert_due_date(date
|
388
|
+
def convert_due_date(date)
|
397
389
|
due = nil
|
398
390
|
day_index = @due_date_days.index(date.to_s.downcase) ||
|
399
391
|
DUE_DATE_DAYS_SIMPLE.index(date.to_s.downcase) ||
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: todo-jsonl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.25
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabor Bata
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-03-
|
11
|
+
date: 2021-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|