todo-jsonl 0.1.21 → 0.1.22
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 +27 -9
- 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: 1c785fb535af9ce8e4aa7104e57c66133f6bf201ffb6bc28372d2b386decc4e1
|
4
|
+
data.tar.gz: 6ce70f3e7160c997921bcdbacb442d9e04330019265e60ad4accab1a1cf386ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18781618d8824776f157cce55015bdd49cd4d68791a6c4f24d86d9f66acb331ef4f2e2b22b1f8577e1f92f32bb232dbb061afa66f8f59aa7bc07bb0bc6d29083
|
7
|
+
data.tar.gz: e0544156459535841c4be51378071f40dda66f945733acf927328930699d0bd3d5b111996ea73cfd5f89f13418617a037d5e418f255093ac95f2d2689ce49da5
|
data/bin/todo.rb
CHANGED
@@ -120,6 +120,9 @@ class Todo
|
|
120
120
|
when 'repl'
|
121
121
|
raise action + ' command has no parameters' if args.length > 0
|
122
122
|
start_repl
|
123
|
+
when 'cleanup'
|
124
|
+
raise action + ' command requires at least one parameter' if args.nil? || args.empty?
|
125
|
+
cleanup(args)
|
123
126
|
else
|
124
127
|
list(nil, arguments)
|
125
128
|
end
|
@@ -152,6 +155,7 @@ class Todo
|
|
152
155
|
* list <regex> [regex...] list tasks (only active tasks by default)
|
153
156
|
* show <tasknumber> show all task details
|
154
157
|
* repl enter read-eval-print loop mode
|
158
|
+
* cleanup <regex> [regex...] cleanup completed tasks by regexp
|
155
159
|
* help this help screen
|
156
160
|
|
157
161
|
With list command the following pre-defined regex patterns can be also used:
|
@@ -293,18 +297,10 @@ class Todo
|
|
293
297
|
end
|
294
298
|
|
295
299
|
def list(tasks = nil, patterns = nil)
|
296
|
-
items = {}
|
297
300
|
tasks = tasks || load_tasks
|
298
301
|
task_indent = [tasks.keys.max.to_s.size, 4].max
|
299
302
|
patterns = patterns.nil? || patterns.empty? ? [@queries[':active']] : patterns
|
300
|
-
|
301
|
-
normalized_task = "state=#{task[:state]} due=#{task[:due]} #{task[:title]}"
|
302
|
-
match = true
|
303
|
-
patterns.each do |pattern|
|
304
|
-
match = false unless /#{@queries[pattern] || pattern}/ix.match(normalized_task)
|
305
|
-
end
|
306
|
-
items[num] = task if match
|
307
|
-
end
|
303
|
+
items = filter_tasks(tasks, patterns)
|
308
304
|
items = items.sort_by do |num, task|
|
309
305
|
[task[:priority] && task[:state] != 'done' ? 0 : 1, ORDER[task[:state] || 'default'], task[:due] || 'n/a', num]
|
310
306
|
end
|
@@ -371,6 +367,28 @@ class Todo
|
|
371
367
|
end
|
372
368
|
end
|
373
369
|
|
370
|
+
def cleanup(patterns)
|
371
|
+
tasks = load_tasks
|
372
|
+
patterns = [@queries[':done']] + patterns.to_a
|
373
|
+
items = filter_tasks(tasks, patterns)
|
374
|
+
items.keys.each do |num| tasks.delete(num) end
|
375
|
+
write_tasks(tasks)
|
376
|
+
puts "deleted #{items.size} todo(s)"
|
377
|
+
end
|
378
|
+
|
379
|
+
def filter_tasks(tasks, patterns)
|
380
|
+
items = {}
|
381
|
+
tasks.each do |num, task|
|
382
|
+
normalized_task = "state=#{task[:state]} due=#{task[:due]} #{task[:title]}"
|
383
|
+
match = true
|
384
|
+
patterns.each do |pattern|
|
385
|
+
match = false unless /#{@queries[pattern] || pattern}/ix.match(normalized_task)
|
386
|
+
end
|
387
|
+
items[num] = task if match
|
388
|
+
end
|
389
|
+
return items
|
390
|
+
end
|
391
|
+
|
374
392
|
def colorize(text, color)
|
375
393
|
"\e[#{COLOR_CODES[color]}m#{text}\e[0m"
|
376
394
|
end
|
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.22
|
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-05 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|