hiiro 0.1.251 → 0.1.252
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/CHANGELOG.md +1 -1
- data/CLAUDE.md +33 -1
- data/bin/h-title +56 -0
- data/lib/hiiro/input_file.rb +78 -0
- data/lib/hiiro/queue.rb +7 -15
- data/lib/hiiro/runner_tool.rb +4 -8
- data/lib/hiiro/service_manager.rb +4 -8
- data/lib/hiiro/task_colors.rb +38 -0
- data/lib/hiiro/tasks.rb +37 -10
- data/lib/hiiro/version.rb +1 -1
- data/lib/hiiro.rb +20 -1
- metadata +4 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b727d51b49863c23d01b1230c420149bf0266b050caf73b17b8e7914c0db01f6
|
|
4
|
+
data.tar.gz: 6dac86e2dd81358b9b2cf78bd0021e6ce8429d1c91553cb201092712c1cf35cb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a9e10b9fd6f8056ce061028c6f60f0727885f8ecfb33ceded5bf31a5aea30584fa1333974d00f2a4a64e39cdb7f21859fe00ec16476f582245556f3c08f303fb
|
|
7
|
+
data.tar.gz: f1253163887e6ac44e65b7e95cb4cb4ad76e0124402030f68ef326a62ca71e5c2d93fa59b928a8ef13d7444bfe84bb04d987ab28357269b2e5d70b16bd36cd33
|
data/CHANGELOG.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Done.
|
|
1
|
+
Done. I've created a new v0.1.252 section at the top of CHANGELOG.md dated 2026-03-14, consolidating the recent commits into concise Added and Changed sections. The previous Unreleased section remains below for ongoing development work.
|
data/CLAUDE.md
CHANGED
|
@@ -174,7 +174,8 @@ Instance methods available in subcommand blocks:
|
|
|
174
174
|
- `pins` - Key-value storage per command
|
|
175
175
|
- `todo_manager` - Todo item management
|
|
176
176
|
- `attach_method(name, &block)` - Add methods to hiiro instance dynamically
|
|
177
|
-
- `make_child(subcmd, *args)` - Create nested Hiiro for sub-subcommands
|
|
177
|
+
- `make_child(subcmd, *args)` - Create nested Hiiro for sub-subcommands (returns instance, must call `.run` manually)
|
|
178
|
+
- `run_child(subcmd, *args)` - Create a nested Hiiro instance AND immediately run it (preferred over `make_child(...).run`)
|
|
178
179
|
|
|
179
180
|
### Hiiro::Matcher (lib/hiiro/matcher.rb)
|
|
180
181
|
|
|
@@ -417,6 +418,37 @@ Config: `~/.config/hiiro/jumplist/` (per-client entries and position files, max
|
|
|
417
418
|
|
|
418
419
|
Dead panes are automatically pruned. Duplicate consecutive entries are deduplicated. Forward history is truncated when navigating to a new location (like vim).
|
|
419
420
|
|
|
421
|
+
### Using `run_child`
|
|
422
|
+
|
|
423
|
+
`run_child` is the instance-level equivalent of `Hiiro.run` — it creates a child Hiiro instance scoped to a subcommand and immediately dispatches it. Use it instead of `make_child(...).run`:
|
|
424
|
+
|
|
425
|
+
```ruby
|
|
426
|
+
# Inside a subcommand handler or plugin:
|
|
427
|
+
hiiro.add_subcmd(:service) do |*args|
|
|
428
|
+
sm = ServiceManager.new
|
|
429
|
+
hiiro.run_child(:service) do |h|
|
|
430
|
+
h.add_subcmd(:list) { sm.list }
|
|
431
|
+
h.add_subcmd(:start) { |name| sm.start(name) }
|
|
432
|
+
end
|
|
433
|
+
end
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
This is equivalent to `hiiro.make_child(:service) { ... }.run`, but cleaner and mirrors the `Hiiro.run` / `Hiiro.init` relationship.
|
|
437
|
+
|
|
438
|
+
## Coding Rules and Conventions
|
|
439
|
+
|
|
440
|
+
### `Hiiro.run` is mandatory for `bin/` files
|
|
441
|
+
|
|
442
|
+
New `bin/h-*` files MUST always use `Hiiro.run`. NEVER use `Hiiro.init` or call `Hiiro.load_env` directly in bin files. `Hiiro.init` returns an instance without running it — `Hiiro.run` initializes and dispatches immediately, which is always what bin files need.
|
|
443
|
+
|
|
444
|
+
### CHANGELOG.md is append-only
|
|
445
|
+
|
|
446
|
+
ALWAYS add an entry to `CHANGELOG.md` when making changes. NEVER remove or modify existing entries. New entries go at the top.
|
|
447
|
+
|
|
448
|
+
### Keep docs current
|
|
449
|
+
|
|
450
|
+
ALWAYS update `README.md` and any files in `docs/` or other markdown files that describe how to use hiiro, its bins, or how it works whenever you change behavior. Never let these go stale.
|
|
451
|
+
|
|
420
452
|
## Key Files
|
|
421
453
|
|
|
422
454
|
- `exe/h` - Entry point that loads lib/hiiro.rb
|
data/bin/h-title
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "hiiro"
|
|
4
|
+
require "fileutils"
|
|
5
|
+
|
|
6
|
+
Hiiro.run(*ARGV) do
|
|
7
|
+
add_subcmd(:update) do
|
|
8
|
+
session_name = `tmux display-message -p '\#{session_name}' 2>/dev/null`.strip
|
|
9
|
+
next if session_name.empty?
|
|
10
|
+
|
|
11
|
+
env = Hiiro::Environment.current
|
|
12
|
+
task = env.all_tasks.find { |t| t.session_name == session_name }
|
|
13
|
+
title = task ? task.name : session_name
|
|
14
|
+
|
|
15
|
+
client_tty = `tmux display-message -p '\#{client_tty}' 2>/dev/null`.strip
|
|
16
|
+
next if client_tty.empty?
|
|
17
|
+
|
|
18
|
+
begin
|
|
19
|
+
File.write(client_tty, "\033]0;#{title}\007")
|
|
20
|
+
rescue
|
|
21
|
+
# best-effort; silently ignore permission errors
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
add_subcmd(:setup) do
|
|
26
|
+
conf_dir = File.join(Dir.home, '.config', 'tmux')
|
|
27
|
+
conf_file = File.join(conf_dir, 'h-title.tmux.conf')
|
|
28
|
+
tmux_conf = File.join(Dir.home, '.tmux.conf')
|
|
29
|
+
source_line = "source-file #{conf_file}"
|
|
30
|
+
|
|
31
|
+
FileUtils.mkdir_p(conf_dir)
|
|
32
|
+
|
|
33
|
+
title_conf = <<~CONF
|
|
34
|
+
# --- Terminal tab title hooks (h-title) ---
|
|
35
|
+
set-hook -g client-session-changed "run-shell -b 'h title update'"
|
|
36
|
+
set-hook -g after-new-session "run-shell -b 'h title update'"
|
|
37
|
+
CONF
|
|
38
|
+
|
|
39
|
+
File.write(conf_file, title_conf)
|
|
40
|
+
puts "Wrote #{conf_file}"
|
|
41
|
+
|
|
42
|
+
if File.exist?(tmux_conf)
|
|
43
|
+
existing = File.read(tmux_conf)
|
|
44
|
+
if existing.include?(source_line)
|
|
45
|
+
puts "#{tmux_conf} already sources #{conf_file}"
|
|
46
|
+
next
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
File.open(tmux_conf, 'a') do |f|
|
|
51
|
+
f.puts
|
|
52
|
+
f.puts source_line
|
|
53
|
+
end
|
|
54
|
+
puts "Added '#{source_line}' to #{tmux_conf}"
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
require 'tempfile'
|
|
2
|
+
require 'yaml'
|
|
3
|
+
|
|
4
|
+
class Hiiro
|
|
5
|
+
class InputFile
|
|
6
|
+
EXTENSIONS = { yaml: '.yml', md: '.md' }.freeze
|
|
7
|
+
|
|
8
|
+
def self.yaml_file(hiiro:, content: nil, append: false, prefix: 'edit-')
|
|
9
|
+
new(hiiro: hiiro, type: :yaml, content: content, append: append, prefix: prefix)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def self.md_file(hiiro:, content: nil, append: false, prefix: 'edit-')
|
|
13
|
+
new(hiiro: hiiro, type: :md, content: content, append: append, prefix: prefix)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
attr_reader :hiiro, :type, :content, :append, :prefix
|
|
17
|
+
|
|
18
|
+
def initialize(hiiro:, type: :md, content: nil, append: false, prefix: 'edit-')
|
|
19
|
+
@hiiro = hiiro
|
|
20
|
+
@type = type
|
|
21
|
+
@content = content
|
|
22
|
+
@append = append
|
|
23
|
+
@prefix = prefix
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Lazily creates, pre-fills, and closes the tempfile.
|
|
27
|
+
# The file is not created until it's first needed.
|
|
28
|
+
def tmpfile
|
|
29
|
+
@tmpfile ||= begin
|
|
30
|
+
tf = Tempfile.new([prefix, EXTENSIONS.fetch(type)])
|
|
31
|
+
tf.write(content) if content
|
|
32
|
+
tf.close
|
|
33
|
+
tf
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def edit
|
|
38
|
+
if append && hiiro.vim?
|
|
39
|
+
system(hiiro.editor, '+$', tmpfile.path)
|
|
40
|
+
else
|
|
41
|
+
hiiro.edit_files(tmpfile.path)
|
|
42
|
+
end
|
|
43
|
+
self
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def path
|
|
47
|
+
tmpfile.path
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# The raw text the user wrote, stripped of leading/trailing whitespace.
|
|
51
|
+
def contents
|
|
52
|
+
@contents ||= File.read(tmpfile.path).strip
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Parses the file contents according to type:
|
|
56
|
+
# :yaml → Hash or Array (via YAML.safe_load)
|
|
57
|
+
# :md → FrontMatterParser::Document (call .front_matter, .content)
|
|
58
|
+
def parsed_file(permitted_classes: [])
|
|
59
|
+
@parsed_file ||= case type
|
|
60
|
+
when :yaml
|
|
61
|
+
YAML.safe_load_file(tmpfile.path, permitted_classes:) rescue nil
|
|
62
|
+
when :md
|
|
63
|
+
require 'front_matter_parser'
|
|
64
|
+
FrontMatterParser::Parser.parse_file(tmpfile.path)
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def empty?
|
|
69
|
+
contents.empty?
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Deletes the tempfile. Call when done with the input.
|
|
73
|
+
# Safe to call even if the file was never materialized.
|
|
74
|
+
def cleanup
|
|
75
|
+
@tmpfile&.unlink
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
data/lib/hiiro/queue.rb
CHANGED
|
@@ -3,8 +3,6 @@ require 'fileutils'
|
|
|
3
3
|
require 'shellwords'
|
|
4
4
|
require 'time'
|
|
5
5
|
require 'front_matter_parser'
|
|
6
|
-
require 'tempfile'
|
|
7
|
-
|
|
8
6
|
class Hiiro
|
|
9
7
|
class Queue
|
|
10
8
|
DIR = Hiiro::Config.data_path('queue')
|
|
@@ -470,32 +468,26 @@ class Hiiro
|
|
|
470
468
|
ti = (ti || {}).merge(session_name: session_name) if session_name
|
|
471
469
|
end
|
|
472
470
|
|
|
473
|
-
tmpfile = Tempfile.new(['hq-', '.md'])
|
|
474
|
-
prompt_file = tmpfile.path
|
|
475
471
|
if args.empty? && !$stdin.tty?
|
|
476
472
|
content = $stdin.read.strip
|
|
477
473
|
elsif args.any?
|
|
478
474
|
content = args.join(' ')
|
|
479
475
|
else
|
|
480
476
|
# Pre-fill with frontmatter template if task_info is available
|
|
481
|
-
if ti
|
|
477
|
+
fm_content = if ti
|
|
482
478
|
fm_lines = ["---"]
|
|
483
479
|
fm_lines << "task_name: #{ti[:task_name]}" if ti[:task_name]
|
|
484
480
|
fm_lines << "tree_name: #{ti[:tree_name]}" if ti[:tree_name]
|
|
485
481
|
fm_lines << "session_name: #{ti[:session_name]}" if ti[:session_name]
|
|
486
482
|
fm_lines << "---"
|
|
487
|
-
fm_lines << "
|
|
488
|
-
|
|
483
|
+
fm_lines << ""
|
|
484
|
+
fm_lines.join("\n")
|
|
489
485
|
end
|
|
490
486
|
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
system(h.editor, tmpfile.path)
|
|
496
|
-
end
|
|
497
|
-
content = File.read(tmpfile.path).strip
|
|
498
|
-
tmpfile.unlink
|
|
487
|
+
input = InputFile.md_file(hiiro: h, content: fm_content, append: !!fm_content, prefix: 'hq-')
|
|
488
|
+
input.edit
|
|
489
|
+
content = input.contents
|
|
490
|
+
input.cleanup
|
|
499
491
|
if content.empty?
|
|
500
492
|
puts "Aborted (empty file)"
|
|
501
493
|
next
|
data/lib/hiiro/runner_tool.rb
CHANGED
|
@@ -194,22 +194,18 @@ class Hiiro
|
|
|
194
194
|
'file_extensions' => '',
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
tmpfile.write(YAML.dump({ 'new_tool' => template }))
|
|
200
|
-
tmpfile.close
|
|
201
|
-
|
|
202
|
-
h.edit_files(tmpfile.path)
|
|
197
|
+
input = InputFile.yaml_file(hiiro: h, content: YAML.dump({ 'new_tool' => template }), prefix: 'tool')
|
|
198
|
+
input.edit
|
|
203
199
|
|
|
204
200
|
begin
|
|
205
|
-
data =
|
|
201
|
+
data = input.parsed_file(permitted_classes: [Symbol]) || {}
|
|
206
202
|
data.each do |name, cfg|
|
|
207
203
|
rt.add_tool({ 'name' => name }.merge(cfg || {}))
|
|
208
204
|
end
|
|
209
205
|
rescue => e
|
|
210
206
|
puts "Error parsing config: #{e.message}"
|
|
211
207
|
ensure
|
|
212
|
-
|
|
208
|
+
input.cleanup
|
|
213
209
|
end
|
|
214
210
|
end
|
|
215
211
|
|
|
@@ -641,22 +641,18 @@ class Hiiro
|
|
|
641
641
|
],
|
|
642
642
|
}
|
|
643
643
|
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
tmpfile.write(YAML.dump({ 'new_service' => template }))
|
|
647
|
-
tmpfile.close
|
|
648
|
-
|
|
649
|
-
h.edit_files(tmpfile.path)
|
|
644
|
+
input = InputFile.yaml_file(hiiro: h, content: YAML.dump({ 'new_service' => template }), prefix: 'service')
|
|
645
|
+
input.edit
|
|
650
646
|
|
|
651
647
|
begin
|
|
652
|
-
data =
|
|
648
|
+
data = input.parsed_file(permitted_classes: [Symbol]) || {}
|
|
653
649
|
data.each do |name, cfg|
|
|
654
650
|
sm.add_service({ 'name' => name }.merge(cfg || {}))
|
|
655
651
|
end
|
|
656
652
|
rescue => e
|
|
657
653
|
puts "Error parsing config: #{e.message}"
|
|
658
654
|
ensure
|
|
659
|
-
|
|
655
|
+
input.cleanup
|
|
660
656
|
end
|
|
661
657
|
end
|
|
662
658
|
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
class Hiiro
|
|
2
|
+
module TaskColors
|
|
3
|
+
# 12 visually distinct, dark-background color pairs for tmux status bars.
|
|
4
|
+
# All use colour255 (white) as foreground for readability.
|
|
5
|
+
PALETTE = [
|
|
6
|
+
{ bg: 'colour24', fg: 'colour255' }, # 0: Steel blue
|
|
7
|
+
{ bg: 'colour88', fg: 'colour255' }, # 1: Dark red
|
|
8
|
+
{ bg: 'colour28', fg: 'colour255' }, # 2: Forest green
|
|
9
|
+
{ bg: 'colour130', fg: 'colour255' }, # 3: Sienna
|
|
10
|
+
{ bg: 'colour54', fg: 'colour255' }, # 4: Purple
|
|
11
|
+
{ bg: 'colour23', fg: 'colour255' }, # 5: Dark teal
|
|
12
|
+
{ bg: 'colour52', fg: 'colour255' }, # 6: Crimson
|
|
13
|
+
{ bg: 'colour58', fg: 'colour255' }, # 7: Olive
|
|
14
|
+
{ bg: 'colour17', fg: 'colour255' }, # 8: Navy
|
|
15
|
+
{ bg: 'colour90', fg: 'colour255' }, # 9: Magenta
|
|
16
|
+
{ bg: 'colour94', fg: 'colour255' }, # 10: Burnt orange
|
|
17
|
+
{ bg: 'colour22', fg: 'colour255' }, # 11: Dark forest
|
|
18
|
+
].freeze
|
|
19
|
+
|
|
20
|
+
def self.for_index(index)
|
|
21
|
+
PALETTE[index.to_i % PALETTE.size]
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Apply status-bg / status-fg to the named tmux session.
|
|
25
|
+
def self.apply(session_name, color_index)
|
|
26
|
+
colors = for_index(color_index)
|
|
27
|
+
system('tmux', 'set-option', '-t', session_name, 'status-bg', colors[:bg])
|
|
28
|
+
system('tmux', 'set-option', '-t', session_name, 'status-fg', colors[:fg])
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Return the first palette index not already used by existing_indices,
|
|
32
|
+
# falling back to modulo wrap-around when all colors are taken.
|
|
33
|
+
def self.next_index(existing_indices)
|
|
34
|
+
(0...PALETTE.size).find { |i| !existing_indices.include?(i) } ||
|
|
35
|
+
(existing_indices.length % PALETTE.size)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
data/lib/hiiro/tasks.rb
CHANGED
|
@@ -117,7 +117,8 @@ class Hiiro
|
|
|
117
117
|
apply_sparse_checkout(target_path, sparse_groups) if sparse_groups.any?
|
|
118
118
|
|
|
119
119
|
session_name = task_name
|
|
120
|
-
|
|
120
|
+
color_index = Hiiro::TaskColors.next_index(config.tasks.map(&:color_index).compact)
|
|
121
|
+
task = Task.new(name: task_name, tree: subtree_name, session: session_name, color_index: color_index)
|
|
121
122
|
config.save_task(task)
|
|
122
123
|
|
|
123
124
|
base_dir = target_path
|
|
@@ -127,6 +128,11 @@ class Hiiro
|
|
|
127
128
|
end
|
|
128
129
|
|
|
129
130
|
Dir.chdir(base_dir)
|
|
131
|
+
# Create the session detached first so colors are applied before the user attaches
|
|
132
|
+
unless system('tmux', 'has-session', '-t', session_name, err: File::NULL)
|
|
133
|
+
system('tmux', 'new-session', '-d', '-s', session_name, '-c', Dir.pwd)
|
|
134
|
+
end
|
|
135
|
+
Hiiro::TaskColors.apply(session_name, color_index)
|
|
130
136
|
hiiro.start_tmux_session(session_name)
|
|
131
137
|
|
|
132
138
|
puts "Started task '#{task_name}' in worktree '#{subtree_name}'"
|
|
@@ -150,6 +156,7 @@ class Hiiro
|
|
|
150
156
|
puts "Session '#{session_name}' is already attached. Use -f to switch anyway."
|
|
151
157
|
exit 1
|
|
152
158
|
end
|
|
159
|
+
Hiiro::TaskColors.apply(session_name, task.color_index) if task.color_index
|
|
153
160
|
hiiro.start_tmux_session(session_name)
|
|
154
161
|
else
|
|
155
162
|
base_dir = tree_path
|
|
@@ -160,6 +167,11 @@ class Hiiro
|
|
|
160
167
|
|
|
161
168
|
if Dir.exist?(base_dir)
|
|
162
169
|
Dir.chdir(base_dir)
|
|
170
|
+
# Create detached first so colors are applied before the user attaches
|
|
171
|
+
unless system('tmux', 'has-session', '-t', session_name, err: File::NULL)
|
|
172
|
+
system('tmux', 'new-session', '-d', '-s', session_name, '-c', Dir.pwd)
|
|
173
|
+
end
|
|
174
|
+
Hiiro::TaskColors.apply(session_name, task.color_index) if task.color_index
|
|
163
175
|
hiiro.start_tmux_session(session_name)
|
|
164
176
|
else
|
|
165
177
|
puts "ERROR: Path '#{base_dir}' does not exist"
|
|
@@ -618,6 +630,7 @@ class Hiiro
|
|
|
618
630
|
h = { 'name' => name }
|
|
619
631
|
h['tree'] = data['tree'] if data['tree']
|
|
620
632
|
h['session'] = data['session'] if data['session']
|
|
633
|
+
h['color_index'] = data['color_index'] if data['color_index']
|
|
621
634
|
h
|
|
622
635
|
end
|
|
623
636
|
return { 'tasks' => tasks }
|
|
@@ -680,13 +693,10 @@ class Hiiro
|
|
|
680
693
|
task_names = tm.tasks.map(&:name)
|
|
681
694
|
task_lines = task_names.map { |n| "- #{n}" }
|
|
682
695
|
yaml_content = "# Select tasks to tag.\n\ntasks:\n#{task_lines.join("\n")}\n\ntags:\n-\n"
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
h.edit_files(tmpfile.path)
|
|
688
|
-
parsed = YAML.safe_load(File.read(tmpfile.path)) rescue nil
|
|
689
|
-
tmpfile.unlink
|
|
696
|
+
input = InputFile.yaml_file(hiiro: h, content: yaml_content, prefix: 'task-tag-')
|
|
697
|
+
input.edit
|
|
698
|
+
parsed = input.parsed_file
|
|
699
|
+
input.cleanup
|
|
690
700
|
selected = Array(parsed&.dig('tasks')).map(&:to_s).reject(&:empty?)
|
|
691
701
|
new_tags = Array(parsed&.dig('tags')).map(&:to_s).reject(&:empty?)
|
|
692
702
|
if selected.empty? || new_tags.empty?
|
|
@@ -905,6 +915,21 @@ class Hiiro
|
|
|
905
915
|
|
|
906
916
|
h.add_subcmd(:save) { tm.save }
|
|
907
917
|
|
|
918
|
+
h.add_subcmd(:color) do
|
|
919
|
+
task = tm.current_task
|
|
920
|
+
unless task
|
|
921
|
+
puts "Not in a task session"
|
|
922
|
+
next
|
|
923
|
+
end
|
|
924
|
+
unless task.color_index
|
|
925
|
+
puts "No color assigned to task '#{task.name}'"
|
|
926
|
+
next
|
|
927
|
+
end
|
|
928
|
+
Hiiro::TaskColors.apply(task.session_name, task.color_index)
|
|
929
|
+
colors = Hiiro::TaskColors.for_index(task.color_index)
|
|
930
|
+
puts "Applied color theme #{task.color_index}: bg=#{colors[:bg]} fg=#{colors[:fg]}"
|
|
931
|
+
end
|
|
932
|
+
|
|
908
933
|
h.add_subcmd(:stop) do |task_name=nil|
|
|
909
934
|
if task_name.nil?
|
|
910
935
|
selected = tm.select_task_interactive
|
|
@@ -1113,12 +1138,13 @@ class Hiiro
|
|
|
1113
1138
|
end
|
|
1114
1139
|
|
|
1115
1140
|
class Task
|
|
1116
|
-
attr_reader :name, :tree_name, :session_name
|
|
1141
|
+
attr_reader :name, :tree_name, :session_name, :color_index
|
|
1117
1142
|
|
|
1118
|
-
def initialize(name:, tree: nil, session: nil, **_)
|
|
1143
|
+
def initialize(name:, tree: nil, session: nil, color_index: nil, **_)
|
|
1119
1144
|
@name = name
|
|
1120
1145
|
@tree_name = tree
|
|
1121
1146
|
@session_name = session || name
|
|
1147
|
+
@color_index = color_index
|
|
1122
1148
|
end
|
|
1123
1149
|
|
|
1124
1150
|
def parent_name
|
|
@@ -1162,6 +1188,7 @@ class Hiiro
|
|
|
1162
1188
|
h = { name: name }
|
|
1163
1189
|
h[:tree] = tree_name if tree_name
|
|
1164
1190
|
h[:session] = session_name if session_name != name
|
|
1191
|
+
h[:color_index] = color_index unless color_index.nil?
|
|
1165
1192
|
h
|
|
1166
1193
|
end
|
|
1167
1194
|
|
data/lib/hiiro/version.rb
CHANGED
data/lib/hiiro.rb
CHANGED
|
@@ -13,9 +13,11 @@ require_relative "hiiro/glob"
|
|
|
13
13
|
require_relative "hiiro/matcher"
|
|
14
14
|
require_relative "hiiro/notification"
|
|
15
15
|
require_relative "hiiro/options"
|
|
16
|
+
require_relative "hiiro/input_file"
|
|
16
17
|
require_relative "hiiro/paths"
|
|
17
18
|
require_relative "hiiro/tags"
|
|
18
19
|
require_relative "hiiro/queue"
|
|
20
|
+
require_relative "hiiro/task_colors"
|
|
19
21
|
require_relative "hiiro/tasks"
|
|
20
22
|
require_relative "hiiro/tmux"
|
|
21
23
|
require_relative "hiiro/todo"
|
|
@@ -162,6 +164,14 @@ class Hiiro
|
|
|
162
164
|
editor.to_s.match?(/vim/i)
|
|
163
165
|
end
|
|
164
166
|
|
|
167
|
+
def yaml_input_file(content: nil, append: false, prefix: 'edit-')
|
|
168
|
+
InputFile.yaml_file(hiiro: self, content:, append:, prefix:)
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
def md_input_file(content: nil, append: false, prefix: 'edit-')
|
|
172
|
+
InputFile.md_file(hiiro: self, content:, append:, prefix:)
|
|
173
|
+
end
|
|
174
|
+
|
|
165
175
|
def edit_files(*files, max_splits: 3)
|
|
166
176
|
if editor.match?(/vim/i)
|
|
167
177
|
if files.count > max_splits.to_i
|
|
@@ -191,6 +201,10 @@ class Hiiro
|
|
|
191
201
|
Hiiro.init(bin_name: child_bin_name, args: child_args, **kwargs, &block)
|
|
192
202
|
end
|
|
193
203
|
|
|
204
|
+
def run_child(custom_subcmd=nil, custom_args=nil, **kwargs, &block)
|
|
205
|
+
make_child(custom_subcmd, custom_args, **kwargs, &block).run
|
|
206
|
+
end
|
|
207
|
+
|
|
194
208
|
def todo_manager
|
|
195
209
|
@todo_manager ||= TodoManager.new
|
|
196
210
|
end
|
|
@@ -200,7 +214,8 @@ class Hiiro
|
|
|
200
214
|
end
|
|
201
215
|
|
|
202
216
|
def run
|
|
203
|
-
|
|
217
|
+
run_args = runners.using_default? ? [subcmd, *args].compact : args
|
|
218
|
+
result = runner.run(*run_args)
|
|
204
219
|
|
|
205
220
|
handle_result(result)
|
|
206
221
|
|
|
@@ -485,6 +500,10 @@ class Hiiro
|
|
|
485
500
|
@default_subcommand
|
|
486
501
|
end
|
|
487
502
|
|
|
503
|
+
def using_default?
|
|
504
|
+
!exact_runner && !unambiguous_runner
|
|
505
|
+
end
|
|
506
|
+
|
|
488
507
|
def subcommand_names
|
|
489
508
|
all_runners.map(&:subcommand_name)
|
|
490
509
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: hiiro
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.252
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Joshua Toyota
|
|
@@ -117,6 +117,7 @@ files:
|
|
|
117
117
|
- bin/h-project
|
|
118
118
|
- bin/h-session
|
|
119
119
|
- bin/h-sha
|
|
120
|
+
- bin/h-title
|
|
120
121
|
- bin/h-todo
|
|
121
122
|
- bin/h-window
|
|
122
123
|
- bin/h-wtree
|
|
@@ -261,6 +262,7 @@ files:
|
|
|
261
262
|
- lib/hiiro/git/worktree.rb
|
|
262
263
|
- lib/hiiro/git/worktrees.rb
|
|
263
264
|
- lib/hiiro/glob.rb
|
|
265
|
+
- lib/hiiro/input_file.rb
|
|
264
266
|
- lib/hiiro/matcher.rb
|
|
265
267
|
- lib/hiiro/notification.rb
|
|
266
268
|
- lib/hiiro/options.rb
|
|
@@ -271,6 +273,7 @@ files:
|
|
|
271
273
|
- lib/hiiro/service_manager.rb
|
|
272
274
|
- lib/hiiro/shell.rb
|
|
273
275
|
- lib/hiiro/tags.rb
|
|
276
|
+
- lib/hiiro/task_colors.rb
|
|
274
277
|
- lib/hiiro/tasks.rb
|
|
275
278
|
- lib/hiiro/tmux.rb
|
|
276
279
|
- lib/hiiro/tmux/buffer.rb
|