hiiro 0.1.176 → 0.1.177

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: 0c7c9cf34fb45c193f3ad936e411d4e3517a9f824be6df484cfd36845bfc3200
4
- data.tar.gz: b975e3bde79da4fad9d5f3c84d57cf29c670c0dcda4e7e5838d7c3c4840666ae
3
+ metadata.gz: 1dd88812c94c3cdeacee1bbbaac20b15f0bbf4f510db38216a5100758818bdfb
4
+ data.tar.gz: 56ac6a005a636507b3a38635cfaa8cd974e9e460392e5ac5bf3a1935079fc7ac
5
5
  SHA512:
6
- metadata.gz: 16f7d1a7c31d5f460b1f448a232ba06a782cfbdf915a915e66d6bc59c69d314a108a819fa76391b9007b528f0b1a0b5744fbc326e11d1ef5e7ba42e9bc75a674
7
- data.tar.gz: 769ea579bffecdd99e8638875dbdb026d02be55e88c719da6ed43da33ace8354a41185c522f193ed615b5834ef56d1d5d545ad2b4b43abb72df38796d956c611
6
+ metadata.gz: fb744d6d49cc35a78dbeb1ace6d108584dc49d00d2eb8394e945e5e92b56ba0742cf429f0f4cf49a17da1f41d67f238143543ab7689dda1bd6f195780d5dcf8d
7
+ data.tar.gz: 81823bd0b80c7613ed743f18b7fccf87e904c93d3c3ba77017fcb9704a5d0c942d7df1a22be5e59009fb264fc8e0ab72130efa1addc83d743007ba92fcc675e1
data/lib/hiiro/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Hiiro
2
- VERSION = "0.1.176"
2
+ VERSION = "0.1.177"
3
3
  end
data/lib/hiiro.rb CHANGED
@@ -301,20 +301,80 @@ class Hiiro
301
301
  end
302
302
 
303
303
  def list_runners(list)
304
- max_name = list.map { |r| r.subcommand_name.length }.max || 0
305
- max_type = list.map { |r| r.type.to_s.length }.max || 0
306
- max_params = list.map { |r| r.params_string.to_s.length }.max || 0
307
-
308
- list.each do |r|
309
- name = r.subcommand_name.ljust(max_name)
310
- type = "(#{r.type})".ljust(max_type + 2)
311
- params = r.params_string
304
+ sorted = list.sort_by(&:subcommand_name)
305
+ vars = build_location_vars(sorted)
306
+
307
+ vars.each { |var_name, path| puts "export #{var_name}=\"#{path}\"" }
308
+ puts if vars.any?
309
+
310
+ max_name = sorted.map { |r| r.subcommand_name.length }.max || 0
311
+ max_type = sorted.map { |r| r.type.to_s.length }.max || 0
312
+ max_params = sorted.map { |r| r.params_string.to_s.length }.max || 0
313
+
314
+ sorted.each do |r|
315
+ name = r.subcommand_name.ljust(max_name)
316
+ type = "(#{r.type})".ljust(max_type + 2)
317
+ params = r.params_string
312
318
  params_col = params ? params.ljust(max_params) : ''.ljust(max_params)
313
- location = r.location
319
+ location = shorten_location(r.location, vars)
314
320
  puts " #{name} #{params_col} #{type} #{location}"
315
321
  end
316
322
  end
317
323
 
324
+ def build_location_vars(list)
325
+ paths = list.map { |r| r.location }.compact.map { |loc| loc.sub(/:\d+$/, '') }
326
+ dirs = paths.map { |p| File.dirname(p) }.uniq
327
+
328
+ ancestors = consolidate_dirs(dirs, min_depth: 4)
329
+
330
+ vars = {}
331
+ ancestors.sort.each do |ancestor|
332
+ name = auto_var_name(ancestor, vars)
333
+ vars[name] = ancestor
334
+ end
335
+ vars
336
+ end
337
+
338
+ # Recursively group directories under their common ancestor when that
339
+ # ancestor is deep enough to be a useful alias (>= min_depth components).
340
+ def consolidate_dirs(dirs, min_depth:)
341
+ return dirs if dirs.length <= 1
342
+
343
+ lca = dirs.reduce { |a, b| path_lca(a, b) }
344
+ lca_depth = lca.delete_prefix('/').split('/').reject(&:empty?).length
345
+
346
+ if lca_depth >= min_depth
347
+ [lca]
348
+ else
349
+ lca_parts = lca.split('/')
350
+ subgroups = dirs.group_by { |d| d.split('/').first(lca_parts.length + 1).join('/') }
351
+ subgroups.flat_map { |_, group| consolidate_dirs(group, min_depth: min_depth) }.uniq
352
+ end
353
+ end
354
+
355
+ def path_lca(a, b)
356
+ a_parts = a.split('/')
357
+ b_parts = b.split('/')
358
+ a_parts.zip(b_parts).take_while { |x, y| x == y }.map(&:first).join('/')
359
+ end
360
+
361
+ def auto_var_name(path, existing_vars)
362
+ parts = path.delete_prefix('/').split('/')
363
+ (1..parts.length).each do |n|
364
+ candidate = parts.last(n).join('_').upcase.gsub(/[^A-Z0-9]/, '_').squeeze('_').delete_prefix('_').delete_suffix('_')
365
+ return candidate unless existing_vars.key?(candidate)
366
+ end
367
+ "DIR_#{existing_vars.length + 1}"
368
+ end
369
+
370
+ def shorten_location(loc, vars)
371
+ return loc if loc.nil?
372
+ vars.sort_by { |_, path| -path.length }.each do |var_name, path|
373
+ return loc.sub(path, "$#{var_name}") if loc.start_with?(path + '/') || loc == path
374
+ end
375
+ loc
376
+ end
377
+
318
378
  def log(message)
319
379
  return unless logging
320
380
 
@@ -0,0 +1,25 @@
1
+ ## `hiiro`
2
+
3
+ New AI Workflow Utilities
4
+ ---
5
+ > Technology is supposed to make our lives easier, allowing us to do things more quickly and efficiently.
6
+ > - James Surowiecki
7
+
8
+ ---
9
+ #### Pain Points
10
+
11
+ Thanks to AI, some pain points are becoming increasingly more common.
12
+
13
+ ---
14
+ I've added 2 new features to `hiiro` that help to relieve some of the pain related to these issues.
15
+
16
+ ---
17
+ #### Pain Points (cont'd)
18
+
19
+ - **Context switching** - increased cognitive load jumping from task to task
20
+ - `h queue`
21
+ - `h task queue` - integrated into task management
22
+ - **Managing Servers/Services**
23
+ - `h service`
24
+
25
+ ---
data/slides.md CHANGED
@@ -58,7 +58,7 @@ Hiiro shows the candidates.
58
58
  `h s` matches several commands:
59
59
 
60
60
  ```bash
61
- h s || true
61
+ h s
62
62
  ```
63
63
 
64
64
  ---
@@ -70,7 +70,7 @@ A longer prefix narrows the match.
70
70
  `h se` gets closer:
71
71
 
72
72
  ```bash
73
- h se || true
73
+ h se
74
74
  ```
75
75
 
76
76
  ---
@@ -110,7 +110,7 @@ h task
110
110
  List current tasks:
111
111
 
112
112
  ```bash
113
- h task ls || true
113
+ h task ls
114
114
  ```
115
115
 
116
116
  ---
@@ -120,7 +120,7 @@ h task ls || true
120
120
  `h ta ls` = `h task ls`
121
121
 
122
122
  ```bash
123
- h ta ls || true
123
+ h ta ls
124
124
  ```
125
125
 
126
126
  ---
@@ -140,7 +140,7 @@ h subtask
140
140
  List current subtasks:
141
141
 
142
142
  ```bash
143
- h subtask ls || true
143
+ h subtask ls
144
144
  ```
145
145
 
146
146
  ---
@@ -150,7 +150,7 @@ h subtask ls || true
150
150
  `h su ls` = `h subtask ls`
151
151
 
152
152
  ```bash
153
- h su ls || true
153
+ h su ls
154
154
  ```
155
155
 
156
156
  ---
@@ -170,7 +170,7 @@ h queue
170
170
  List queued jobs:
171
171
 
172
172
  ```bash
173
- h queue ls || true
173
+ h queue ls
174
174
  ```
175
175
 
176
176
  ---
@@ -180,7 +180,7 @@ h queue ls || true
180
180
  Show queue status:
181
181
 
182
182
  ```bash
183
- h queue status || true
183
+ h queue status
184
184
  ```
185
185
 
186
186
  ---
@@ -190,7 +190,7 @@ h queue status || true
190
190
  `h q ls` = `h queue ls`
191
191
 
192
192
  ```bash
193
- h q ls || true
193
+ h q ls
194
194
  ```
195
195
 
196
196
  ---
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.176
4
+ version: 0.1.177
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Toyota
@@ -166,6 +166,7 @@ files:
166
166
  - lib/hiiro/todo.rb
167
167
  - lib/hiiro/version.rb
168
168
  - notes
169
+ - obsidian_slides.md
169
170
  - plugins/notify.rb
170
171
  - plugins/pins.rb
171
172
  - plugins/project.rb