hiiro 0.1.108 → 0.1.110
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/lib/hiiro/queue.rb +38 -10
- data/lib/hiiro/version.rb +1 -1
- 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: 1176422e5141f9d92675e0c430c61f251a6cf6e0a6d4dbcdfb603f9f26ae686f
|
|
4
|
+
data.tar.gz: 273d517bbf2dfa725b68c23c11b7aeee42300a627c279c7f8c590165735cc02a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 822986bd56d1ec140c77bdf7ce5e6dcbd85d7d848b4617963ba5ad498a1dd5c8c36e419d545a3938dad5205b519172d7d1163f1e91b58a0def569306da6f29e8
|
|
7
|
+
data.tar.gz: 71423aeb97b38805a9304965b483437a2af3e9a0fa64a83f7565e908553c8df88486058545e6656e3299753bbe9746cfe384a0458ae999607caf6cad61ff6237
|
data/lib/hiiro/queue.rb
CHANGED
|
@@ -169,6 +169,29 @@ class Hiiro
|
|
|
169
169
|
puts "Launched: #{name} [#{target_session}:#{win_name}]"
|
|
170
170
|
end
|
|
171
171
|
|
|
172
|
+
def task_info_for(task_name)
|
|
173
|
+
env = Environment.current rescue nil
|
|
174
|
+
return nil unless env
|
|
175
|
+
|
|
176
|
+
task = env.find_task(task_name)
|
|
177
|
+
return nil unless task
|
|
178
|
+
|
|
179
|
+
{
|
|
180
|
+
task_name: task.subtask? ? task.parent_name : task.name,
|
|
181
|
+
tree_name: task.tree_name,
|
|
182
|
+
session_name: task.session_name,
|
|
183
|
+
}
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
def extract_task_flag(args)
|
|
187
|
+
idx = args.index('-t')
|
|
188
|
+
return [args, nil] unless idx
|
|
189
|
+
|
|
190
|
+
task_name = args[idx + 1]
|
|
191
|
+
remaining = args[0...idx] + args[(idx + 2)..]
|
|
192
|
+
[remaining, task_name]
|
|
193
|
+
end
|
|
194
|
+
|
|
172
195
|
def strip_frontmatter(text)
|
|
173
196
|
lines = text.lines
|
|
174
197
|
return text unless lines.first&.strip == '---'
|
|
@@ -356,6 +379,8 @@ class Hiiro
|
|
|
356
379
|
|
|
357
380
|
h.add_subcmd(:add) { |*args|
|
|
358
381
|
q.queue_dirs
|
|
382
|
+
args, flag_task = q.extract_task_flag(args)
|
|
383
|
+
ti = flag_task ? q.task_info_for(flag_task) : task_info
|
|
359
384
|
|
|
360
385
|
if args.empty? && !$stdin.tty?
|
|
361
386
|
content = $stdin.read.strip
|
|
@@ -366,11 +391,11 @@ class Hiiro
|
|
|
366
391
|
tmpfile = Tempfile.new(['hq-', '.md'])
|
|
367
392
|
|
|
368
393
|
# Pre-fill with frontmatter template if task_info is available
|
|
369
|
-
if
|
|
394
|
+
if ti
|
|
370
395
|
fm_lines = ["---"]
|
|
371
|
-
fm_lines << "task_name: #{
|
|
372
|
-
fm_lines << "tree_name: #{
|
|
373
|
-
fm_lines << "session_name: #{
|
|
396
|
+
fm_lines << "task_name: #{ti[:task_name]}" if ti[:task_name]
|
|
397
|
+
fm_lines << "tree_name: #{ti[:tree_name]}" if ti[:tree_name]
|
|
398
|
+
fm_lines << "session_name: #{ti[:session_name]}" if ti[:session_name]
|
|
374
399
|
fm_lines << "---"
|
|
375
400
|
fm_lines << ""
|
|
376
401
|
tmpfile.write(fm_lines.join("\n"))
|
|
@@ -387,7 +412,7 @@ class Hiiro
|
|
|
387
412
|
end
|
|
388
413
|
end
|
|
389
414
|
|
|
390
|
-
result = q.add_with_frontmatter(content, task_info:
|
|
415
|
+
result = q.add_with_frontmatter(content, task_info: ti)
|
|
391
416
|
if result
|
|
392
417
|
puts "Created: #{result[:path]}"
|
|
393
418
|
else
|
|
@@ -395,9 +420,12 @@ class Hiiro
|
|
|
395
420
|
end
|
|
396
421
|
}
|
|
397
422
|
|
|
398
|
-
h.add_subcmd(:wip) { |
|
|
423
|
+
h.add_subcmd(:wip) { |*args|
|
|
399
424
|
q.queue_dirs
|
|
400
425
|
editor = ENV['EDITOR'] || 'vim'
|
|
426
|
+
args, flag_task = q.extract_task_flag(args)
|
|
427
|
+
ti = flag_task ? q.task_info_for(flag_task) : task_info
|
|
428
|
+
name = args.first
|
|
401
429
|
|
|
402
430
|
if name.nil?
|
|
403
431
|
existing = q.tasks_in(:wip)
|
|
@@ -415,11 +443,11 @@ class Hiiro
|
|
|
415
443
|
|
|
416
444
|
unless File.exist?(path)
|
|
417
445
|
# Pre-fill with frontmatter if task_info available
|
|
418
|
-
if
|
|
446
|
+
if ti
|
|
419
447
|
fm_lines = ["---"]
|
|
420
|
-
fm_lines << "task_name: #{
|
|
421
|
-
fm_lines << "tree_name: #{
|
|
422
|
-
fm_lines << "session_name: #{
|
|
448
|
+
fm_lines << "task_name: #{ti[:task_name]}" if ti[:task_name]
|
|
449
|
+
fm_lines << "tree_name: #{ti[:tree_name]}" if ti[:tree_name]
|
|
450
|
+
fm_lines << "session_name: #{ti[:session_name]}" if ti[:session_name]
|
|
423
451
|
fm_lines << "---"
|
|
424
452
|
fm_lines << ""
|
|
425
453
|
File.write(path, fm_lines.join("\n"))
|
data/lib/hiiro/version.rb
CHANGED