hiiro 0.1.14 → 0.1.16

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: 120a159138b041e06749ec822d31251a980ff168177a23e62d118ce64a9aa7a3
4
- data.tar.gz: 6e4fbc826a0fc648bc1dd53da2165daf15b081875bce912ff6d8933ca56f5662
3
+ metadata.gz: 79ae7c6943bffba4ffb21c734c699946ec9ee43eb247e8dc1e77532f9fe8b506
4
+ data.tar.gz: 18b3196492b5f9838dabd1cb8085d3184b2798aac27799f28ae114a497025284
5
5
  SHA512:
6
- metadata.gz: 0b943ab68f08a7db203c94c5d1f1b096e0ef0bcc3bdb30ba7556e49bd86cd5b398b87cf6181d676bf609870c11df3aaa124f74035fbc636566f3a21fcfe3a107
7
- data.tar.gz: 4c13f38ad2c94c3fd20c537f6bed9e2bdd865ff09bc03603bf47142387fc340d5a54b5fde18eabfbd0e3a78b8b38bbab78c715f94b9073c185f903371b8e28de
6
+ metadata.gz: ce091b64e298217a27dcd291906e0cd9284ada1ab9654d257632d062c575af95466d06f874328e0f02cce4db17e4d096ab3663763c170952d4d7fe29c3b96ad7
7
+ data.tar.gz: dcc6e3a169b876aaf9f16e6cb7173eda73a71700869bd13e683be87d5f7b6fd56608868f79cff5cb377f448d5334122e947cf232d1321923ad68e669641820fb
data/bin/h-link CHANGED
@@ -39,9 +39,15 @@ def hash_matches?(links, *args)
39
39
  end
40
40
  end
41
41
 
42
- def link_matches?(link, *args)
42
+ def search_links(links, *args)
43
43
  terms = args.map(&:downcase)
44
44
 
45
+ links.select do |link|
46
+ link_matches?(link, *terms)
47
+ end
48
+ end
49
+
50
+ def link_matches?(link, *terms)
45
51
  searchable = [
46
52
  link['url'],
47
53
  link['description'],
@@ -51,6 +57,16 @@ def link_matches?(link, *args)
51
57
  terms.all? { |term| searchable.include?(term) }
52
58
  end
53
59
 
60
+ def load_link_hash(links=nil)
61
+ links ||= load_links
62
+
63
+ links.each_with_index.each_with_object({}) do |(link, idx), h|
64
+ num = (idx + 1).to_s.rjust(3)
65
+ desc = link['description'].to_s.empty? ? "" : " - #{link['description']}"
66
+ h["#{num}. #{link['url']}#{desc}"] = link
67
+ end
68
+ end
69
+
54
70
  def load_links
55
71
  ensure_links_file
56
72
  YAML.load_file(LINKS_FILE) || []
@@ -162,16 +178,13 @@ end
162
178
 
163
179
  o.add_subcmd(:select) do |*args|
164
180
  links = load_links
181
+
165
182
  if links.empty?
166
183
  STDERR.puts "No links saved."
167
184
  exit 1
168
185
  end
169
186
 
170
- lines = links.each_with_index.each_with_object({}) do |(link, idx), h|
171
- num = (idx + 1).to_s.rjust(3)
172
- desc = link['description'].to_s.empty? ? "" : " - #{link['description']}"
173
- h["#{num}. #{link['url']}#{desc}"] = link
174
- end
187
+ lines = load_link_hash(links)
175
188
 
176
189
  if args.any?
177
190
  lines = hash_matches?(lines, *args)
@@ -222,14 +235,40 @@ o.add_subcmd(:edit) do |*args|
222
235
  end
223
236
 
224
237
  o.add_subcmd(:open) do |*args|
238
+ links = load_links
239
+
225
240
  if args.empty?
226
- puts "Usage: h link open <number|shorthand>"
227
- exit 1
241
+ lines = load_link_hash(links)
242
+
243
+ exit_code = 1
244
+
245
+ if args.any?
246
+ lines = hash_matches?(lines, *args)
247
+ end
248
+
249
+ require 'open3'
250
+ selected, status = Open3.capture2('sk', stdin_data: lines.keys.join("\n"))
251
+
252
+ if status.success? && !selected.strip.empty?
253
+ if selected =~ /^\s*(\d+)\.\s+(\S+)/
254
+ system('open', $2)
255
+ exit_code = 0
256
+ end
257
+ end
258
+
259
+ exit exit_code
228
260
  end
229
261
 
230
- links = load_links
231
262
  idx, link = find_link_by_ref(args.first, links)
232
263
 
264
+ if link.nil?
265
+ matches = search_links(links, *args)
266
+
267
+ if matches.count == 1
268
+ link = matches.first
269
+ end
270
+ end
271
+
233
272
  if link.nil?
234
273
  puts "Link not found: #{args.first}"
235
274
  exit 1
data/lib/hiiro/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Hiiro
2
- VERSION = "0.1.14"
2
+ VERSION = "0.1.16"
3
3
  end
data/links.backup.yml ADDED
@@ -0,0 +1,13 @@
1
+ ---
2
+ - url: http://auth.unixsuperhero.com:9969
3
+ description: stash
4
+ shorthand: fap
5
+ created_at: '2026-01-27T00:58:36-05:00'
6
+ - url: http://auth.unixsuperhero.com:8012
7
+ description: utorrent
8
+ shorthand: utor
9
+ created_at: '2026-01-27T22:10:55-05:00'
10
+ - url: http://auth.unixsuperhero.com:3005
11
+ description: sandbox nas
12
+ shorthand: sandbox
13
+ created_at: '2026-01-27T22:12:16-05:00'
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.14
4
+ version: 0.1.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Toyota
@@ -62,6 +62,7 @@ files:
62
62
  - hiiro.gemspec
63
63
  - lib/hiiro.rb
64
64
  - lib/hiiro/version.rb
65
+ - links.backup.yml
65
66
  - plugins/notify.rb
66
67
  - plugins/pins.rb
67
68
  - plugins/project.rb