hiiro 0.1.109 → 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 -11
- 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 == '---'
|
|
@@ -231,7 +254,6 @@ class Hiiro
|
|
|
231
254
|
q ||= current(parent_hiiro)
|
|
232
255
|
|
|
233
256
|
parent_hiiro.make_child do |h|
|
|
234
|
-
binding.pry
|
|
235
257
|
h.add_subcmd(:watch) {
|
|
236
258
|
q.queue_dirs
|
|
237
259
|
puts "Watching #{File.join(DIR, 'pending')} ..."
|
|
@@ -357,6 +379,8 @@ class Hiiro
|
|
|
357
379
|
|
|
358
380
|
h.add_subcmd(:add) { |*args|
|
|
359
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
|
|
360
384
|
|
|
361
385
|
if args.empty? && !$stdin.tty?
|
|
362
386
|
content = $stdin.read.strip
|
|
@@ -367,11 +391,11 @@ class Hiiro
|
|
|
367
391
|
tmpfile = Tempfile.new(['hq-', '.md'])
|
|
368
392
|
|
|
369
393
|
# Pre-fill with frontmatter template if task_info is available
|
|
370
|
-
if
|
|
394
|
+
if ti
|
|
371
395
|
fm_lines = ["---"]
|
|
372
|
-
fm_lines << "task_name: #{
|
|
373
|
-
fm_lines << "tree_name: #{
|
|
374
|
-
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]
|
|
375
399
|
fm_lines << "---"
|
|
376
400
|
fm_lines << ""
|
|
377
401
|
tmpfile.write(fm_lines.join("\n"))
|
|
@@ -388,7 +412,7 @@ class Hiiro
|
|
|
388
412
|
end
|
|
389
413
|
end
|
|
390
414
|
|
|
391
|
-
result = q.add_with_frontmatter(content, task_info:
|
|
415
|
+
result = q.add_with_frontmatter(content, task_info: ti)
|
|
392
416
|
if result
|
|
393
417
|
puts "Created: #{result[:path]}"
|
|
394
418
|
else
|
|
@@ -396,9 +420,12 @@ class Hiiro
|
|
|
396
420
|
end
|
|
397
421
|
}
|
|
398
422
|
|
|
399
|
-
h.add_subcmd(:wip) { |
|
|
423
|
+
h.add_subcmd(:wip) { |*args|
|
|
400
424
|
q.queue_dirs
|
|
401
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
|
|
402
429
|
|
|
403
430
|
if name.nil?
|
|
404
431
|
existing = q.tasks_in(:wip)
|
|
@@ -416,11 +443,11 @@ class Hiiro
|
|
|
416
443
|
|
|
417
444
|
unless File.exist?(path)
|
|
418
445
|
# Pre-fill with frontmatter if task_info available
|
|
419
|
-
if
|
|
446
|
+
if ti
|
|
420
447
|
fm_lines = ["---"]
|
|
421
|
-
fm_lines << "task_name: #{
|
|
422
|
-
fm_lines << "tree_name: #{
|
|
423
|
-
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]
|
|
424
451
|
fm_lines << "---"
|
|
425
452
|
fm_lines << ""
|
|
426
453
|
File.write(path, fm_lines.join("\n"))
|
data/lib/hiiro/version.rb
CHANGED