todo-jsonl 1.0.3 → 1.0.4
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 +15 -19
- 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: fc4e0e129e6dae5b09b233027e88344b5439b805a732a97c9162ea0cd57159d4
|
4
|
+
data.tar.gz: 3d521e8f11ccc2295bc32bc7bfdea49aca23c7b55023b19b8d90a8a0f002229a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75b546efb040d46254728b62a5d27962d9a96495a1c0295bc334580ac88beeaeb611359e04e881baa846de199684486850f96390b8efff2445e506375eab0bc0
|
7
|
+
data.tar.gz: c6115760b9b524d8624ccd8491119b289a5def26910c07b1cf5d295c91ad84e07a3dbb71ae6dc44dfa7fc838a666cac67dd922aa954b1660cb1a93a79611b7ab
|
data/bin/todo.rb
CHANGED
@@ -107,8 +107,8 @@ class Todo
|
|
107
107
|
raise action + ' command requires at least two parameters' if args.length < 2
|
108
108
|
add_note(args.first.to_i, args[1..-1].join(' '))
|
109
109
|
when 'delnote'
|
110
|
-
raise action + ' command requires
|
111
|
-
delete_note(args.first.to_i)
|
110
|
+
raise action + ' command requires one or two parameters' if args.length < 1 || args.length > 2
|
111
|
+
delete_note(args.first.to_i, args[1])
|
112
112
|
when 'list'
|
113
113
|
list(nil, args)
|
114
114
|
when 'show'
|
@@ -151,7 +151,7 @@ class Todo
|
|
151
151
|
* rename <tasknumber> <text> rename task
|
152
152
|
* del <tasknumber> delete task
|
153
153
|
* note <tasknumber> <text> add note to task
|
154
|
-
* delnote <tasknumber>
|
154
|
+
* delnote <tasknumber> [number] delete a specific or all notes from task
|
155
155
|
|
156
156
|
* list <regex> [regex...] list tasks (only active tasks by default)
|
157
157
|
* show <tasknumber> show all task details
|
@@ -212,9 +212,7 @@ class Todo
|
|
212
212
|
|
213
213
|
def write_tasks(tasks)
|
214
214
|
File.open(TODO_FILE, 'w:UTF-8') do |file|
|
215
|
-
tasks.keys.sort.each
|
216
|
-
file.write(JSON.generate(tasks[key]) + "\n")
|
217
|
-
end
|
215
|
+
tasks.keys.sort.each { |key| file.write(JSON.generate(tasks[key]) + "\n") }
|
218
216
|
end
|
219
217
|
end
|
220
218
|
|
@@ -228,15 +226,9 @@ class Todo
|
|
228
226
|
end
|
229
227
|
|
230
228
|
def add(text)
|
231
|
-
task = {
|
232
|
-
state: 'new',
|
233
|
-
title: text,
|
234
|
-
modified: @today.strftime(DATE_FORMAT)
|
235
|
-
}
|
229
|
+
task = { state: 'new', title: text, modified: @today.strftime(DATE_FORMAT) }
|
236
230
|
postprocess_tags(task)
|
237
|
-
File.open(TODO_FILE, 'a:UTF-8')
|
238
|
-
file.write(JSON.generate(task) + "\n")
|
239
|
-
end
|
231
|
+
File.open(TODO_FILE, 'a:UTF-8') { |file| file.write(JSON.generate(task) + "\n") }
|
240
232
|
list
|
241
233
|
end
|
242
234
|
|
@@ -344,17 +336,21 @@ class Todo
|
|
344
336
|
end)
|
345
337
|
end
|
346
338
|
|
347
|
-
def delete_note(item)
|
339
|
+
def delete_note(item, num = nil)
|
348
340
|
update_task(item, :show, lambda do |task|
|
349
|
-
task.delete(:note)
|
341
|
+
return task.delete(:note) if num.to_s.empty?
|
342
|
+
raise "#{num.to_i}: Note does not exist" if num.to_i <= 0 || task[:note].to_a.size < num.to_i
|
343
|
+
task[:note].delete_at(num.to_i - 1)
|
344
|
+
task.delete(:note) if task[:note].empty?
|
350
345
|
end)
|
351
346
|
end
|
352
347
|
|
353
348
|
def show(item, tasks = nil)
|
354
349
|
tasks ||= load_tasks(item)
|
355
|
-
tasks[item].each do |
|
356
|
-
|
357
|
-
|
350
|
+
tasks[item].each do |k, v|
|
351
|
+
v = "\n" + v.each_with_index.map { |n, i| "#{(i + 1).to_s.rjust(v.size.to_s.size, ' ')}: #{n}" }.
|
352
|
+
join("\n") if v.is_a?(Array)
|
353
|
+
puts "#{colorize(k.to_s.rjust(10, ' ') + ':', :cyan)} #{v}"
|
358
354
|
end
|
359
355
|
end
|
360
356
|
|
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: 1.0.
|
4
|
+
version: 1.0.4
|
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-24 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|