hiiro 0.1.31 → 0.1.33.pre.1

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: f9acf06495590129ec1870e030280f89addc30177e768c360aa8e6891d69ece7
4
- data.tar.gz: afdc44652ae0ea1efbc107f8bd4b972c88477f07cf247665a66104859f49a0c2
3
+ metadata.gz: b2e1bf3310b631a31f3eddd49217193c44f9b7a080ca200db1524e3dbb80f8c3
4
+ data.tar.gz: efcf8d31f760fafde059592b53469189c7b21ac3a6650334e381fbf7a9a6c97a
5
5
  SHA512:
6
- metadata.gz: 74d7b72bcb20c9cfdde0ef7c63d02d270f6f95fd05510fb5ff25f0543c4830f15418718f693fce532c8388f9c9a80851a9d13969646d75b187119f08d3d9cd64
7
- data.tar.gz: 5f00c18b9bf9c47f8063a37dd6984bcbf97d7bdc4d06f06d918e1aa93aa48c316a14fd76301c56e029eafab2acacbc163f3e50c040b6d85f64217611554a56ae
6
+ metadata.gz: 4056150e8f6605fe2568e39e84413581edb31170bd7a93ceb8891513c94305d6a3c30bab948adbba193ae599dee6d43fe04dbeb83f3d0009795b60bb12009fa0
7
+ data.tar.gz: a8b364f3931e8597c254a1fdcd9f59442f6e9c74912985396dd2466289e43a1663edb9b92336c57115681a1a36a78ff68cc98e48ad34586db7feff1454d3a987
data/README.md CHANGED
@@ -19,7 +19,7 @@ See [docs/](docs/) for detailed documentation on all subcommands.
19
19
  gem install hiiro
20
20
 
21
21
  # Install plugins and subcommands
22
- hiiro setup
22
+ h setup
23
23
  ```
24
24
 
25
25
  This installs:
@@ -28,26 +28,15 @@ This installs:
28
28
 
29
29
  Ensure `~/bin` is in your `$PATH`.
30
30
 
31
- ### Manual Installation
32
-
33
- ```sh
34
- # Copy the main script
35
- cp bin/h ~/bin/h
36
- chmod +x ~/bin/h
37
-
38
- # Copy subcommands (optional)
39
- cp bin/h-* ~/bin/
40
-
41
- # Copy plugins (optional)
42
- mkdir -p ~/.config/hiiro/plugins
43
- cp plugins/*.rb ~/.config/hiiro/plugins/
44
- ```
45
31
 
46
32
  ### Dependencies
47
33
 
48
34
  ```sh
49
35
  # For notify plugin (macOS)
50
36
  brew install terminal-notifier
37
+
38
+ # For fuzzy-finder
39
+ brew install sk
51
40
  ```
52
41
 
53
42
  ## Quick Start
@@ -56,14 +45,6 @@ brew install terminal-notifier
56
45
  # List available subcommands
57
46
  h
58
47
 
59
- # Edit the main h script
60
- h edit
61
-
62
- # Get paths
63
- h path # Print current directory
64
- h ppath # Print project root (git repo root + relative dir)
65
- h rpath # Print relative directory from git root
66
-
67
48
  # Simple test
68
49
  h ping
69
50
  # => pong
data/TODO.md ADDED
@@ -0,0 +1,21 @@
1
+
2
+ # To do...
3
+
4
+ - [ ] move task/subtask back into a plugin
5
+ - [ ] have it add :task and :subtask subcommands to the instance of Hiiro
6
+ - [ ] they should init another hiiro instance with a `scope` value set
7
+ - [ ] if scope is :task, it looks at the whole world
8
+ - [ ] if the scope is :subtask, it scopes behavior to the current task
9
+ - [ ] redesign the yml structure for managing tasks
10
+
11
+ ```yml
12
+ tasks:
13
+ - name: some_name
14
+ parent_task: parent_task_name (if included it's a subtask)
15
+ tree: tree_name
16
+ root: repo_root/tree_name
17
+ ```
18
+ - [ ] refactor task plugin to not be procedural AI slop
19
+ - [ ] convert to js and using node
20
+ - [ ] h-config {vim,zsh,tmux}
21
+ - [ ]
data/bin/g-pr CHANGED
@@ -6,8 +6,7 @@ require "fileutils"
6
6
  require "yaml"
7
7
  require "json"
8
8
 
9
- Hiiro.load_env
10
- hiiro = Hiiro.init(*ARGV, plugins: [Task, Tmux, Pins])
9
+ hiiro = Hiiro.init(*ARGV, plugins: [:OldTask, :Tmux, :Pins])
11
10
 
12
11
  class PRManager
13
12
  attr_reader :hiiro
data/bin/h-branch CHANGED
@@ -4,8 +4,7 @@ require "hiiro"
4
4
  require "fileutils"
5
5
  require "yaml"
6
6
 
7
- Hiiro.load_env
8
- hiiro = Hiiro.init(*ARGV, plugins: [Task])
7
+ hiiro = Hiiro.init(*ARGV, plugins: [:OldTask])
9
8
 
10
9
  class BranchManager
11
10
  attr_reader :hiiro
data/bin/h-buffer CHANGED
@@ -12,7 +12,7 @@ def find_buffer(partial)
12
12
  buffer
13
13
  end
14
14
 
15
- o = Hiiro.init(*ARGV, plugins: [Pins])
15
+ o = Hiiro.init(*ARGV, plugins: [:Pins])
16
16
 
17
17
  o.add_subcmd(:ls) { |*args|
18
18
  system('tmux', 'list-buffers', *args)
data/bin/h-link CHANGED
@@ -193,7 +193,7 @@ class LinkManager
193
193
  end
194
194
 
195
195
  lm = LinkManager.new
196
- o = Hiiro.init(*ARGV, plugins: [Tmux, Pins], links_file: lm.links_file)
196
+ o = Hiiro.init(*ARGV, plugins: [:Tmux, :Pins], links_file: lm.links_file)
197
197
 
198
198
  o.add_subcmd(:add) do |*args|
199
199
  links = lm.load_links
@@ -7,8 +7,7 @@ require "fileutils"
7
7
  require "yaml"
8
8
  require "time"
9
9
 
10
- Hiiro.load_env
11
- hiiro = Hiiro.init(*ARGV, plugins: [Tmux, Task])
10
+ hiiro = Hiiro.init(*ARGV, plugins: [:Tmux, :OldTask])
12
11
 
13
12
  tasks = hiiro.task_manager
14
13
 
@@ -5,7 +5,7 @@ require "fileutils"
5
5
  require "yaml"
6
6
  require "pathname"
7
7
 
8
- hiiro = Hiiro.init(*ARGV, plugins: [Tmux])
8
+ hiiro = Hiiro.init(*ARGV, plugins: [:Tmux])
9
9
 
10
10
  class TaskManager
11
11
  attr_reader :hiiro
data/bin/h-pane CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  load File.join(Dir.home, 'bin', 'h')
4
4
 
5
- o = Hiiro.init(*ARGV, plugins: [Pins])
5
+ o = Hiiro.init(*ARGV, plugins: [:Pins])
6
6
 
7
7
  o.add_subcmd(:ls) { |*args|
8
8
  system('tmux', 'list-panes', *args)
data/bin/h-plugin CHANGED
@@ -5,7 +5,7 @@ require 'json'
5
5
  require 'hiiro'
6
6
 
7
7
  BASE_DIR = File.join(Dir.home, '.config/hiiro/plugins')
8
- o = Hiiro.init(*ARGV, plugins: [Tmux, Pins], dir: BASE_DIR)
8
+ o = Hiiro.init(*ARGV, plugins: [:Tmux, :Pins], dir: BASE_DIR)
9
9
 
10
10
  def plugin_files
11
11
  Dir.glob(File.join(BASE_DIR, '**/*'))
data/bin/h-pr CHANGED
@@ -6,8 +6,7 @@ require "fileutils"
6
6
  require "yaml"
7
7
  require "json"
8
8
 
9
- Hiiro.load_env
10
- hiiro = Hiiro.init(*ARGV, plugins: [Task, Tmux, Pins])
9
+ hiiro = Hiiro.init(*ARGV, plugins: [:OldTask, :Tmux, :Pins])
11
10
 
12
11
  class PRManager
13
12
  attr_reader :hiiro
data/bin/h-session CHANGED
@@ -22,7 +22,7 @@ require 'rspec'
22
22
  # has (subcommand) /Users/unixsuperhero/bin/h-session:139
23
23
  # info (subcommand) /Users/unixsuperhero/bin/h-session:143
24
24
 
25
- o = Hiiro.init(*ARGV, plugins: [Pins])
25
+ o = Hiiro.init(*ARGV, plugins: [:Pins])
26
26
 
27
27
  o.add_subcmd(:ls) { |*args|
28
28
  system('tmux', 'list-sessions', *args)
data/bin/h-sha CHANGED
@@ -4,7 +4,7 @@ require 'hiiro'
4
4
 
5
5
  BASE_DIR = File.join(Dir.home, 'work/carrot')
6
6
 
7
- Hiiro.init(*ARGV, plugins: [Tmux, Pins, Project]) { |hiiro|
7
+ Hiiro.init(*ARGV, plugins: [:Tmux, :Pins, :Project]) { |hiiro|
8
8
 
9
9
  }.run
10
10
 
data/bin/h-vim CHANGED
@@ -5,7 +5,7 @@ require 'hiiro'
5
5
  BASE_DIR = CONFIG_DIR = File.join(Dir.home, '.config/nvim')
6
6
  TMUX_SESSION_NAME = 'vim'
7
7
 
8
- o = Hiiro.init(*ARGV, plugins: [Tmux, Pins, Project])
8
+ o = Hiiro.init(*ARGV, plugins: [:Tmux, :Pins, :Project])
9
9
 
10
10
  o.add_subcmd(:edit) { |*args|
11
11
  nvim = ENV['EDITOR']
data/bin/h-window CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  load File.join(Dir.home, 'bin', 'h')
4
4
 
5
- o = Hiiro.init(*ARGV, plugins: [Pins])
5
+ o = Hiiro.init(*ARGV, plugins: [:Pins])
6
6
 
7
7
  o.add_subcmd(:ls) { |*args|
8
8
  system('tmux', 'list-windows', *args)
data/exe/h CHANGED
@@ -3,7 +3,7 @@
3
3
  require "hiiro"
4
4
  require "fileutils"
5
5
 
6
- hiiro = Hiiro.init(*ARGV, cwd: Dir.pwd)
6
+ hiiro = Hiiro.init(*ARGV, cwd: Dir.pwd, plugins: [:Tasks])
7
7
 
8
8
  hiiro.add_subcommand(:version) { |*args|
9
9
  puts Hiiro::VERSION
@@ -0,0 +1,64 @@
1
+ class Hiiro
2
+ class Plugins
3
+ class << self
4
+ def load_plugin(name)
5
+ name_str = name.to_s
6
+ return const_get(name_str) if plugin_loaded?(name_str)
7
+
8
+ path = plugin_path(name_str)
9
+ unless path
10
+ warn "[hiiro] plugin not found: #{name_str}"
11
+ return nil
12
+ end
13
+
14
+ module_eval(File.read(path), path, 1)
15
+
16
+ unless const_defined?(name_str, false)
17
+ warn "[hiiro] plugin #{name_str} did not define expected constant"
18
+ return nil
19
+ end
20
+
21
+ @loaded_plugins ||= []
22
+ @loaded_plugins << name_str
23
+ const_get(name_str)
24
+ end
25
+
26
+ def plugin_loaded?(name_str)
27
+ (@loaded_plugins || []).include?(name_str.to_s)
28
+ end
29
+
30
+ def plugin_path(name_str)
31
+ plugin_filename = name_str.underscore + '.rb'
32
+
33
+ paths_to_check = [
34
+ File.join(Dir.home, '.config/hiiro/plugins'),
35
+ File.join(File.expand_path('../..', __FILE__), 'plugins'),
36
+ ]
37
+
38
+ paths_to_check.each do |dir|
39
+ full_path = File.join(dir, plugin_filename)
40
+ return full_path if File.exist?(full_path)
41
+ end
42
+
43
+ nil
44
+ end
45
+
46
+ def load_all
47
+ user_dir = File.join(Dir.home, '.config/hiiro/plugins')
48
+ gem_dir = File.join(File.expand_path('../..', __FILE__), 'plugins')
49
+
50
+ FileUtils.mkdir_p(user_dir) unless Dir.exist?(user_dir)
51
+
52
+ user_files = Dir.glob(File.join(user_dir, '*.rb'))
53
+ user_basenames = user_files.map { |f| File.basename(f) }
54
+
55
+ gem_files = Dir.exist?(gem_dir) ? Dir.glob(File.join(gem_dir, '*.rb')) : []
56
+ fallback_files = gem_files.reject { |f| user_basenames.include?(File.basename(f)) }
57
+
58
+ (user_files + fallback_files).each do |path|
59
+ module_eval(File.read(path), path, 1)
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
data/lib/hiiro/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Hiiro
2
- VERSION = "0.1.31"
2
+ VERSION = "0.1.33.pre.1"
3
3
  end
data/lib/hiiro.rb CHANGED
@@ -4,15 +4,29 @@ require "shellwords"
4
4
 
5
5
  require_relative "hiiro/version"
6
6
  require_relative "hiiro/history"
7
+ require_relative "hiiro/plugins"
8
+
9
+ class String
10
+ def underscore(camel_cased_word=self)
11
+ regex = /(?:(?<=([A-Za-z\d]))|\b)((?-mix:(?=a)b))(?=\b|[^a-z])/
12
+ return camel_cased_word.to_s.dup unless /[A-Z-]|::/.match?(camel_cased_word)
13
+ word = camel_cased_word.to_s.gsub("::", "/")
14
+ word.gsub!(regex) { "#{$1 && '_' }#{$2.downcase}" }
15
+ word.gsub!(/(?<=[A-Z])(?=[A-Z][a-z])|(?<=[a-z\d])(?=[A-Z])/, "_")
16
+ word.tr!("-", "_")
17
+ word.downcase!
18
+ word
19
+ end
20
+ end
7
21
 
8
22
  class Hiiro
9
23
  def self.init(*args, plugins: [], logging: false, **values, &block)
10
- load_env
24
+ load_plugins(plugins)
11
25
  args = ARGV if args.empty?
12
26
 
13
27
  new($0, *args, logging: logging, **values).tap do |hiiro|
14
28
  History.load(hiiro)
15
- hiiro.load_plugins(*plugins)
29
+ hiiro.init_plugins(*plugins)
16
30
 
17
31
  hiiro.add_subcmd(:edit, **values) { |*args|
18
32
  system(ENV['EDITOR'] || 'nvim', hiiro.bin)
@@ -28,12 +42,10 @@ class Hiiro
28
42
  hiiro.run
29
43
  end
30
44
 
31
- def self.load_env
32
- Config.plugin_files.each do |plugin_file|
33
- require plugin_file
45
+ def self.load_plugins(plugin_list)
46
+ plugin_list.each do |name|
47
+ Plugins.load_plugin(name.to_s)
34
48
  end
35
-
36
- self
37
49
  end
38
50
 
39
51
  attr_reader :bin, :bin_name, :all_args, :full_command
@@ -119,11 +131,24 @@ class Hiiro
119
131
 
120
132
  def pins = @pins ||= Pin.new(self)
121
133
 
134
+ def init_plugins(*names)
135
+ names.flatten.each do |name|
136
+ plugin_const = Hiiro::Plugins.const_get(name.to_s) rescue nil
137
+ next unless plugin_const
138
+ load_plugin(plugin_const)
139
+ end
140
+ end
141
+
122
142
  def load_plugins(*plugins)
123
143
  plugins.flatten.each { |plugin| load_plugin(plugin) }
124
144
  end
125
145
 
126
- def load_plugin(plugin_const)
146
+ def load_plugin(plugin)
147
+ plugin_const = case plugin
148
+ when Module then plugin
149
+ when String, Symbol then Hiiro::Plugins.load_plugin(plugin.to_s)
150
+ end
151
+ return unless plugin_const
127
152
  return if @loaded_plugins.include?(plugin_const)
128
153
 
129
154
  plugin_const.load(self)
@@ -180,14 +205,6 @@ class Hiiro
180
205
 
181
206
  class Config
182
207
  class << self
183
- def plugin_files
184
- Dir.glob(File.join(plugin_dir, '*'))
185
- end
186
-
187
- def plugin_dir
188
- config_dir('plugins')
189
- end
190
-
191
208
  def config_dir(subdir=nil)
192
209
  File.join(Dir.home, '.config/hiiro', *[subdir].compact).tap do |config_path|
193
210
  FileUtils.mkdir_p(config_path) unless Dir.exist?(config_path)
@@ -437,6 +454,4 @@ class Hiiro
437
454
  end
438
455
  end
439
456
  end
440
-
441
- load_env
442
457
  end
data/notes ADDED
@@ -0,0 +1,224 @@
1
+
2
+ # Principles to use for refactoring
3
+
4
+ - Separate data from behavior - create domain objects and any relevant value objects
5
+
6
+
7
+ # Goals
8
+
9
+ - same code to manage tasks/subtasks
10
+ - just scoped differently
11
+ - if scope is `:task` then consider all tasks, if scope is :subtask then only consider the tasks associated with the parent task
12
+ - extract data objects
13
+ - so our procedures are human and easy af
14
+ - more composable
15
+ - separate presentation layer from the data
16
+
17
+
18
+ # features we want
19
+
20
+ - list tasks/subtasks
21
+ - start a new one (wtree/tmux session)
22
+ - switch between them
23
+ - cd to an app's directory
24
+ - stop a task
25
+ - use yml files to track things
26
+
27
+ turn @plugins/tasks.rb into a plugin similar to @plugins/task.rb
28
+
29
+ but in add_subcommands(hiiro) i want to define 2 subtasks:
30
+ 1. `:task`
31
+ 2. `:subtask`
32
+
33
+ both subcommands should initialize `Tasks.new(hiiro_instance, :task)` or
34
+ `Tasks.new(hiiro_instance, :subtask)` if the subtask subcmd was called
35
+
36
+ then uses the instance of Tasks to either do all the things that it needs to
37
+ do... or just use it to get the data it needs, so that it can do the high level
38
+ things like running tmux or git worktree commands.
39
+ if it doesn't put those things inside Tasks, that would be better, so I can use
40
+ these objects in other places like inside @bin/h-link
41
+
42
+ use the following interface as a guide for how to organize things inside the
43
+ new Tasks plugin
44
+
45
+ # Interface
46
+
47
+ class Environment
48
+ def self.current # => Environment - makes new instance
49
+ def all_tasks # => Task[] - call Task.all and memo cache the result
50
+ def all_sessions # => Session[] - call TmuxSession.all and memo cache the result
51
+ def all_trees # => Tree[] - call Tree.all and memo cache the result
52
+ def task # => Task - move Task.current's behavior into this method, and memo cache the result
53
+ def session # => Session - move TmuxSession.current here and memo cache the result
54
+ def tree # => Tree - move Tree.current here and memo cache the result
55
+
56
+ class Tree
57
+ attr_reader :path, :task, :session
58
+
59
+ def self.current # => Tree - move to Environment#tree
60
+ def self.all # => Tree[]
61
+
62
+ class Session
63
+ attr_reader :name, :task
64
+
65
+ def self.current # => Session - move to Environment#session
66
+ def self.all # => Session[]
67
+
68
+ class Task
69
+ attr_reader :name, :tree, :session, :parent, :subtasks
70
+
71
+ def self.current # => Task - move to Environment#task
72
+ def self.all # => Task[]
73
+
74
+ class App
75
+ attr_reader :name, :path
76
+ def self.current # => App[]
77
+ def self.all # => App[]
78
+
79
+ class Tasks
80
+ attr_reader :hiiro, :scope, :environment
81
+
82
+ def tasks # => Task[]
83
+ def subtasks(task) # => Task[]
84
+ def task_by_name(name) # => Task
85
+ def task_by_tree(tree_name) # => Task
86
+ def task_by_session(session_name) # => Task
87
+ def current_task # => Task
88
+ def current_session # => Session
89
+ def current_tree # => Tree
90
+
91
+ def start_task(name, path) # => Task
92
+ def switch_to_task(task) # => nil
93
+ def stop_task(task) # => nil
94
+ def list(tasks) # => nil # print to screen
95
+ def cd_to_task(task) # => nil
96
+ def cd_to_app(app_name) # => nil
97
+
98
+ class Config
99
+ attr_reader :path
100
+
101
+
102
+
103
+
104
+ # Follow-up prompts
105
+
106
+ ## i forget
107
+
108
+ > when initializing an instance of `Task`...it shouldn't have a `parent_task` or `parent_name` kwarg. it derive that context from the name given. if the name has a `/` in it...then it
109
+ is a subtask and the left side is the parent name and the right side is the subtask name.
110
+
111
+
112
+ ## lots of updates
113
+
114
+ here are some updates i'd like to make:
115
+
116
+ - all arguments received from the user should looking that object using
117
+ - something like `start_with?` so they can abbreviate the names of things to
118
+ match
119
+ - the only special one is task_name or subtask_name...if there is a `/` the
120
+ left side will do the abbreviation lookup on a parent name and the right
121
+ side will do a lookup on the subtask name
122
+ - you might want to add `#find_tree(abbreviated_name)` method to
123
+ Environment
124
+ - you might want to add `#find_session(abbreviated_name)` method to
125
+ Environment
126
+ - you might want to add `#find_app(abbreviated_name)` method to
127
+ Environment
128
+ - you might want to add `#find_task(abbreviated_name)` method to
129
+ Environment, where it does the left/right abbreviation lookups
130
+ - these new methods should help clean up and simplify all the lookups in
131
+ the other methods that typically use `.find{ ... }`
132
+
133
+ - get rid of methods like `apps_hash` and in the places that used it...
134
+ - just use the array returned from `#apps` and the attr_reader methods
135
+ for things like name and path or other values that there are attr_readers
136
+ for.
137
+ - always favor an instance method or attr_reader over exporting something
138
+ like hash
139
+
140
+ - `#start_task` shouldn't take an optional `tree_path` keyword arg
141
+ - instead it should take an optional `app_name` kwarg and set the tmux
142
+ session's base directory to the matching app's configured directory
143
+
144
+ - `#switch_task` should also take an optional `app_name` kwarg. if a tmux
145
+ session already exists, just update the configs, associating the task
146
+ with that app. if the tmux session doesn't exist, use the app's path as the
147
+ base_directory.
148
+
149
+
150
+ here's one fix i really want to get right.
151
+
152
+ right now TasksPlugin has a dispatch method that uses a case statement to
153
+ handle the subcommands. what i'd like instead is for tasks plugin to initialize
154
+ a new instance of `Hiiro` but instead of it receiving it's usual `*ARGV` as
155
+ positional args, you should pass-in t `*hiiro.args` using the existing `hiiro`
156
+ instance. then for the new `Hiiro` instance...before you call `#run` on
157
+ it...add each of the subcommands defined in the case statement using the
158
+ `add_subcmd` method and have the block passed in be the handler for those
159
+ subcommands
160
+
161
+ so something like this:
162
+
163
+ ```ruby
164
+ module TasksPlugin
165
+ # ...
166
+
167
+ def self.add_subcommands(hiiro)
168
+ hiiro.add_subcmd(:task) do |*args|
169
+ mgr = Tasks.new(hiiro, scope: :task)
170
+ new_hiiro = task_hiiro(hiiro, mgr)
171
+ new_hiiro.run
172
+ end
173
+
174
+ hiiro.add_subcmd(:subtask) do |*args|
175
+ mgr = Tasks.new(hiiro, scope: :subtask)
176
+ new_hiiro = task_hiiro(hiiro, mgr)
177
+ new_hiiro.run
178
+ end
179
+ end
180
+
181
+ def self.task_hiiro(parent_hiiro, mgr)
182
+ Hiiro.init(*parent_hiiro.args, mgr: mgr) do |task_hiiro|
183
+ task_hiiro.add_subcmd(:ls) do |*args|
184
+ # TODO: the logic to print out the task list based on mgr's values
185
+ end
186
+
187
+ task_hiiro.add_subcmd(:start) do |task_name, app_name=nil|
188
+ # TODO: the logic to print out the task list based on mgr's values
189
+ # like:
190
+ mgr.start_task(task_name, app_name: app_name)
191
+ end
192
+
193
+ task_hiiro.add_subcmd(:switch) do |task_name, app_name=nil|
194
+ # TODO: the logic to print out the task list based on mgr's values
195
+ mgr.switch_to_task(task_name, app_name: app_name)
196
+
197
+ # but if you need to add logic, i would do it here...like:
198
+ task = mgr.find_task(task_name)
199
+
200
+ if task
201
+ # run cmds to switch to task here...
202
+ else
203
+ # print some msg like no task found
204
+ end
205
+ end
206
+
207
+ # ...
208
+ end
209
+ end
210
+
211
+ # ...
212
+ end
213
+ ```
214
+
215
+ ## third prompt
216
+
217
+ for things like listing and switching subtasks
218
+ always consider the main/parent task as a potential subtask to switch to.
219
+ for lookups, treat the task name as parent name and `main` as the subtask name
220
+ so something like `nameofparent/main`
221
+
222
+
223
+
224
+
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- module Task
3
+ module OldTask
4
4
  def self.load(hiiro)
5
5
  hiiro.load_plugin(Tmux)
6
6
  attach_methods(hiiro)
@@ -79,7 +79,7 @@ module Task
79
79
  def self.attach_methods(hiiro)
80
80
  hiiro.instance_eval do
81
81
  def task_manager
82
- @task_manager ||= Task::TaskManager.new(self)
82
+ @task_manager ||= OldTask::TaskManager.new(self)
83
83
  end
84
84
  end
85
85
  end