hiiro 0.1.281 → 0.1.282

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2971b824a362f42ccbe96d8b7f0dd1c149564d13608cb6c7b516fb0061a97b4e
4
- data.tar.gz: 3f157760a16af934d3a6539d2dc0d446a1c80717479730d777f51d1c24d0d6b3
3
+ metadata.gz: 8d10dfb2efdc2e68a768eacd602f68a4bbf135cd85a7b86266563a7c3b8bab4b
4
+ data.tar.gz: e1cf50a2868b1faa6564720784df11f7da44e8fc7c6491e71ae2dbb0a490566b
5
5
  SHA512:
6
- metadata.gz: cb190b23192eb0a4d6a2f7ceb46ed74dcb5250c292afab7d85050ea5baf81bf4b240b45e1ac4b19102a24921c7268e7c3b150f54c4b9bc5cffba6750f6da530a
7
- data.tar.gz: 000f1e725f76ed5e001d45c0df1c4f9f5f43132508c9da4c5d71053526b62cd7e3ff5fda6fed635534599d15f733fede30ac70ab278394bf78013c6a460b1ecb
6
+ metadata.gz: c35dadabe8a27c255bf5e9a77de91e4f8b321f51f8713ea480b432b7723c2227cc84ecbe8abf94ce7a277787ed1e92ea7b32f3fe33b374c3398d593242775063
7
+ data.tar.gz: 4ae9ad2431d999aff919959d071978c9a420d34eb898f08ca61fe46688d68117c5b8f7aa4245cf02d650cd6fe2b884a43fe3578aa35f071832aae867de1de003
data/CHANGELOG.md CHANGED
@@ -1 +1,9 @@
1
- Done.
1
+ ## [0.1.282] - 2026-03-25
2
+
3
+ ### Changed
4
+ - **h task path/cd/sh**: Reworked to accept `-f`/`-t` flags for task selection
5
+ - **h task path**: Enhanced to support multi-argument glob patterns for file listing within task apps
6
+ - **h task cd/sh**: Now use the same task selection mechanism as `h task path`
7
+ - **TaskManager#send_cd**: Promoted from private to public method
8
+
9
+ ## [0.1.281] - Previous release
data/lib/hiiro/tasks.rb CHANGED
@@ -523,6 +523,15 @@ class Hiiro
523
523
  hiiro.fuzzyfind_from_map(name_map)
524
524
  end
525
525
 
526
+ def send_cd(path)
527
+ pane = ENV['TMUX_PANE']
528
+ if pane
529
+ system('tmux', 'send-keys', '-t', pane, "cd #{path}\n")
530
+ else
531
+ system('tmux', 'send-keys', "cd #{path}\n")
532
+ end
533
+ end
534
+
526
535
  # --- Private helpers ---
527
536
 
528
537
  private
@@ -591,15 +600,6 @@ class Hiiro
591
600
  Hiiro::Git.new(nil, path).sparse_checkout(path, dirs)
592
601
  end
593
602
 
594
- def send_cd(path)
595
- pane = ENV['TMUX_PANE']
596
- if pane
597
- system('tmux', 'send-keys', '-t', pane, "cd #{path}\n")
598
- else
599
- system('tmux', 'send-keys', "cd #{path}\n")
600
- end
601
- end
602
-
603
603
  def capture_tmux_windows(session)
604
604
  output = `tmux list-windows -t #{session} -F '\#{window_index}:\#{window_name}:\#{pane_current_path}' 2>/dev/null`
605
605
  output.lines.map(&:strip).map { |line|
@@ -708,6 +708,32 @@ class Hiiro
708
708
  module Tasks
709
709
  def self.build_hiiro(parent_hiiro, tm)
710
710
  task_hiiro = parent_hiiro.make_child do |h|
711
+
712
+ # Shared task resolver: given parsed opts and remaining positional args,
713
+ # returns [task, remaining_positional]. First positional arg is treated as
714
+ # a task name (prefix-matched) if no -f/-t flag is given; falls back to
715
+ # current task if no match.
716
+ resolve_task = lambda do |opts, positional|
717
+ if opts.find
718
+ sel = tm.select_task_interactive
719
+ next [nil, positional] unless sel
720
+ task = sel.is_a?(Hiiro::Task) ? sel : nil
721
+ [task, positional]
722
+ elsif opts.task
723
+ [tm.task_by_name(opts.task), positional]
724
+ elsif positional.any?
725
+ found = tm.task_by_name(positional.first)
726
+ found ? [found, positional[1..]] : [tm.current_task, positional]
727
+ else
728
+ [tm.current_task, positional]
729
+ end
730
+ end
731
+
732
+ task_opts_block = proc {
733
+ option(:task, short: :t, desc: 'Task name')
734
+ flag(:find, short: :f, desc: 'Choose task interactively')
735
+ }
736
+
711
737
  h.add_subcmd(:list) do |*args|
712
738
  opts = Hiiro::Options.parse(args) { option(:tag, short: 't', desc: 'filter by tag (OR when multiple)', multi: true) }
713
739
  tm.list(tags_filter: Array(opts.tag).reject(&:empty?))
@@ -903,12 +929,61 @@ class Hiiro
903
929
 
904
930
  h.add_subcmd(:apps) { tm.list_apps }
905
931
 
906
- h.add_subcmd(:cd) do |app_name=nil|
907
- tm.cd_to_app(app_name)
932
+ h.add_subcmd(:cd) do |*raw_args|
933
+ opts = Hiiro::Options.parse(raw_args, &task_opts_block)
934
+ task, positional = resolve_task.call(opts, opts.args)
935
+ unless task
936
+ puts "No task found"
937
+ next
938
+ end
939
+ tree = tm.environment.find_tree(task.tree_name)
940
+ tree_path = tree ? tree.path : File.join(Hiiro::WORK_DIR, task.tree_name)
941
+ app_name = positional[0]
942
+ if app_name.nil?
943
+ tm.send_cd(tree_path)
944
+ else
945
+ result = tm.environment.app_matcher.find(app_name)
946
+ unless result.match?
947
+ STDERR.puts "App '#{app_name}' not found"
948
+ next
949
+ end
950
+ tm.send_cd(File.join(tree_path, result.first.item.relative_path))
951
+ end
908
952
  end
909
953
 
910
- h.add_subcmd(:path) do |app_name=nil|
911
- tm.app_path(app_name)
954
+ h.add_subcmd(:path) do |*raw_args|
955
+ opts = Hiiro::Options.parse(raw_args, &task_opts_block)
956
+ task, positional = resolve_task.call(opts, opts.args)
957
+ unless task
958
+ STDERR.puts "No task found"
959
+ next
960
+ end
961
+ tree = tm.environment.find_tree(task.tree_name)
962
+ tree_path = tree ? tree.path : File.join(Hiiro::WORK_DIR, task.tree_name)
963
+
964
+ app_name = positional[0]
965
+ globs = positional[1..]
966
+
967
+ if app_name.nil?
968
+ print tree_path
969
+ next
970
+ end
971
+
972
+ result = tm.environment.app_matcher.find(app_name)
973
+ unless result.match?
974
+ STDERR.puts "App '#{app_name}' not found"
975
+ next
976
+ end
977
+ app_path = File.join(tree_path, result.first.item.relative_path)
978
+
979
+ if globs.empty?
980
+ print app_path
981
+ next
982
+ end
983
+
984
+ globs.each do |pattern|
985
+ Dir.glob(File.join(app_path, pattern)).sort.each { |f| puts f }
986
+ end
912
987
  end
913
988
 
914
989
  h.add_subcmd(:branch) do |task_name=nil|
@@ -947,16 +1022,17 @@ class Hiiro
947
1022
  print task.session_name if task.session_name
948
1023
  end
949
1024
 
950
- h.add_subcmd(:sh) do |task_name=nil, *args|
951
- task = task_name ? tm.task_by_name(task_name) : tm.current_task
1025
+ h.add_subcmd(:sh) do |*raw_args|
1026
+ opts = Hiiro::Options.parse(raw_args, &task_opts_block)
1027
+ task, positional = resolve_task.call(opts, opts.args)
952
1028
  unless task
953
- puts task_name ? "Task '#{task_name}' not found" : "Not in a task session"
1029
+ puts "Not in a task session (use -t or -f to specify)"
954
1030
  next
955
1031
  end
956
1032
  tree = tm.environment.find_tree(task.tree_name)
957
1033
  path = tree ? tree.path : File.join(Hiiro::WORK_DIR, task.tree_name)
958
1034
  Dir.chdir(path)
959
- args.empty? ? exec(ENV['SHELL'] || 'zsh') : exec(*args)
1035
+ positional.empty? ? exec(ENV['SHELL'] || 'zsh') : exec(*positional)
960
1036
  end
961
1037
 
962
1038
  h.add_subcmd(:status) { tm.status }
data/lib/hiiro/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Hiiro
2
- VERSION = "0.1.281"
2
+ VERSION = "0.1.282"
3
3
  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.281
4
+ version: 0.1.282
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Toyota