hookapp 2.0.13 → 2.0.15
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/Gemfile.lock +1 -1
- data/README.md +2 -2
- data/buildnotes.md +2 -0
- data/hook.rdoc +1 -1
- data/html/HookApp.html +107 -28
- data/html/README_rdoc.html +1 -1
- data/html/created.rid +3 -3
- data/html/index.html +1 -1
- data/html/js/search_index.js +1 -1
- data/html/js/search_index.js.gz +0 -0
- data/html/table_of_contents.html +10 -0
- data/lib/hook/hookapp.rb +58 -14
- data/lib/hook/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4020d52eb2430378d681031dcc5f01d944673aa7a3e79e24f148008986dc270e
|
4
|
+
data.tar.gz: 83b862600af8076bdb9d6297475eb4e4ef8102d5d9a1c3c19f3f388e1722bbd9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9e70625eff3b1a098f517b599b4eaadc74cac865127bcb63877c27dd5921265ca601d006903c126198e9821407ae90bc3ce615155105a442c80e4b416da36c6
|
7
|
+
data.tar.gz: 9fb4ef946c78073c24dbc5353dbdd6f98e089a3b30432190d7ae2a833885a5c59ee4ea7ec63643083376afb6a2b036b4614ae603c65e019247c63d90938d0cf6
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -6,7 +6,7 @@ CLI interface for Hook.app (macOS)
|
|
6
6
|
|
7
7
|
This gem includes a `hook` binary that allows interaction with the features of Hook.app.
|
8
8
|
|
9
|
-
*v2.0.
|
9
|
+
*v2.0.15*
|
10
10
|
|
11
11
|
## Installation
|
12
12
|
|
@@ -366,5 +366,5 @@ This software is licensed under the MIT License.
|
|
366
366
|
THE SOFTWARE.
|
367
367
|
|
368
368
|
|
369
|
-
Documentation generated 2022-07-
|
369
|
+
Documentation generated 2022-07-20 08:03
|
370
370
|
|
data/hook.rdoc
CHANGED
data/html/HookApp.html
CHANGED
@@ -80,10 +80,12 @@
|
|
80
80
|
<h3>Methods</h3>
|
81
81
|
|
82
82
|
<ul class="link-list" role="directory">
|
83
|
+
<li ><a href="#method-i-act_on">#act_on</a>
|
83
84
|
<li ><a href="#method-i-all_bookmarks">#all_bookmarks</a>
|
84
85
|
<li ><a href="#method-i-bookmark_for">#bookmark_for</a>
|
85
86
|
<li ><a href="#method-i-bookmark_from_app">#bookmark_from_app</a>
|
86
87
|
<li ><a href="#method-i-browse_bookmarks">#browse_bookmarks</a>
|
88
|
+
<li ><a href="#method-i-browse_linked">#browse_linked</a>
|
87
89
|
<li ><a href="#method-i-clip_bookmark">#clip_bookmark</a>
|
88
90
|
<li ><a href="#method-i-clone_hooks">#clone_hooks</a>
|
89
91
|
<li ><a href="#method-i-copy_bookmark">#copy_bookmark</a>
|
@@ -132,6 +134,45 @@
|
|
132
134
|
<h3>Public Instance Methods</h3>
|
133
135
|
</header>
|
134
136
|
|
137
|
+
<div id="method-i-act_on" class="method-detail ">
|
138
|
+
<div class="method-heading">
|
139
|
+
<span class="method-name">act_on</span><span
|
140
|
+
class="method-args">(url)</span>
|
141
|
+
<span class="method-click-advice">click to toggle source</span>
|
142
|
+
</div>
|
143
|
+
|
144
|
+
<div class="method-description">
|
145
|
+
|
146
|
+
|
147
|
+
<div class="method-source-code" id="act_on-source">
|
148
|
+
<pre><span class="ruby-comment"># File lib/hook/hookapp.rb, line 294</span>
|
149
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">act_on</span>(<span class="ruby-identifier">url</span>)
|
150
|
+
<span class="ruby-identifier">menu_items</span> = [<span class="ruby-string">'Open in default app'</span>]
|
151
|
+
<span class="ruby-keyword">return</span> <span class="ruby-identifier">open_linked</span>(<span class="ruby-identifier">url</span>) <span class="ruby-keyword">unless</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-identifier">url</span>)
|
152
|
+
|
153
|
+
<span class="ruby-identifier">marks</span> = <span class="ruby-identifier">get_hooks</span>(<span class="ruby-identifier">url</span>)
|
154
|
+
<span class="ruby-identifier">menu_items</span> <span class="ruby-operator"><<</span> <span class="ruby-string">'Browse file'</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">marks</span>.<span class="ruby-identifier">count</span>.<span class="ruby-identifier">positive?</span>
|
155
|
+
|
156
|
+
<span class="ruby-identifier">args</span> = [<span class="ruby-string">'--prompt="Choose action > "'</span>,
|
157
|
+
<span class="ruby-string">'--layout=reverse-list'</span>,
|
158
|
+
<span class="ruby-string">'--height=60%'</span>,
|
159
|
+
<span class="ruby-node">"--min-height=#{menu_items.count + 1}"</span>]
|
160
|
+
<span class="ruby-identifier">sel</span> = <span class="ruby-node">`echo #{Shellwords.escape(menu_items.join("\n"))} | '#{fzf}' #{args.join(' ')}`</span>.<span class="ruby-identifier">chomp</span>
|
161
|
+
<span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">sel</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">sel</span>.<span class="ruby-identifier">empty?</span>
|
162
|
+
|
163
|
+
<span class="ruby-keyword">case</span> <span class="ruby-identifier">sel</span>
|
164
|
+
<span class="ruby-keyword">when</span> <span class="ruby-regexp">/Browse file/</span>
|
165
|
+
<span class="ruby-identifier">browse_linked</span>(<span class="ruby-identifier">url</span>)
|
166
|
+
<span class="ruby-keyword">else</span>
|
167
|
+
<span class="ruby-node">`open '#{url}'`</span>
|
168
|
+
<span class="ruby-keyword">end</span>
|
169
|
+
<span class="ruby-keyword">end</span></pre>
|
170
|
+
</div>
|
171
|
+
</div>
|
172
|
+
|
173
|
+
|
174
|
+
</div>
|
175
|
+
|
135
176
|
<div id="method-i-all_bookmarks" class="method-detail ">
|
136
177
|
<div class="method-heading">
|
137
178
|
<span class="method-name">all_bookmarks</span><span
|
@@ -255,28 +296,68 @@
|
|
255
296
|
|
256
297
|
|
257
298
|
<div class="method-source-code" id="browse_bookmarks-source">
|
258
|
-
<pre><span class="ruby-comment"># File lib/hook/hookapp.rb, line
|
299
|
+
<pre><span class="ruby-comment"># File lib/hook/hookapp.rb, line 260</span>
|
259
300
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">browse_bookmarks</span>(<span class="ruby-identifier">glob</span>)
|
301
|
+
<span class="ruby-identifier">glob_all</span> = <span class="ruby-string">'**/*'</span>
|
260
302
|
<span class="ruby-identifier">root</span> = <span class="ruby-keyword">if</span> <span class="ruby-identifier">glob</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Array</span>)
|
261
|
-
<span class="ruby-identifier">glob</span>.<span class="ruby-identifier">count</span>.<span class="ruby-identifier">positive?</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">glob</span> <span class="ruby-operator">:</span> <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">glob</span>(<span class="ruby-
|
303
|
+
<span class="ruby-identifier">glob</span>.<span class="ruby-identifier">count</span>.<span class="ruby-identifier">positive?</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">glob</span> <span class="ruby-operator">:</span> <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">glob</span>(<span class="ruby-identifier">glob_all</span>)
|
262
304
|
<span class="ruby-keyword">elsif</span> <span class="ruby-identifier">glob</span> <span class="ruby-operator">&&</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-identifier">glob</span>)
|
263
305
|
<span class="ruby-identifier">hooks</span> = <span class="ruby-identifier">get_hooks</span>(<span class="ruby-identifier">glob</span>)
|
264
306
|
<span class="ruby-keyword">return</span> <span class="ruby-identifier">select_hook</span>(<span class="ruby-identifier">hooks</span>) <span class="ruby-keyword">unless</span> <span class="ruby-identifier">hooks</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-operator">||</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-identifier">glob</span>)
|
265
307
|
|
266
|
-
<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">glob</span>([<span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-identifier">glob</span>), <span class="ruby-
|
308
|
+
<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">glob</span>([<span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-identifier">glob</span>), <span class="ruby-identifier">glob_all</span>])
|
267
309
|
<span class="ruby-keyword">else</span>
|
268
|
-
<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">glob</span>(<span class="ruby-identifier">glob</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">glob</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-operator">?</span> <span class="ruby-
|
310
|
+
<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">glob</span>(<span class="ruby-identifier">glob</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">glob</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">glob_all</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">glob</span>)
|
269
311
|
<span class="ruby-keyword">end</span>
|
270
312
|
|
271
313
|
<span class="ruby-identifier">args</span> = [<span class="ruby-string">'--layout=reverse-list'</span>,
|
272
|
-
<span class="ruby-string">'--header="esc: cancel, return:
|
314
|
+
<span class="ruby-string">'--header="esc: cancel, return: browse"'</span>,
|
273
315
|
<span class="ruby-string">'--prompt=" Select file > "'</span>,
|
274
316
|
<span class="ruby-string">%(--preview='hook ls {}')</span>,
|
275
317
|
<span class="ruby-string">'--height=60%'</span>,
|
276
318
|
<span class="ruby-string">'--min-height=10'</span>]
|
277
319
|
|
278
|
-
<span class="ruby-identifier">sel</span> = <span class="ruby-node">`echo #{Shellwords.escape(root.join("\n"))} | '#{fzf}' #{args.join(' ')}`</span>.<span class="ruby-identifier">chomp</span>
|
279
|
-
|
320
|
+
<span class="ruby-identifier">sel</span> = <span class="ruby-node">`echo #{Shellwords.escape(root.join("\n"))} | '#{fzf}' #{args.join(' ')}`</span>.<span class="ruby-identifier">chomp</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">"\n"</span>)
|
321
|
+
|
322
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">sel</span>.<span class="ruby-identifier">count</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>
|
323
|
+
<span class="ruby-identifier">marks</span> = <span class="ruby-identifier">get_hooks</span>(<span class="ruby-identifier">sel</span>[<span class="ruby-value">0</span>])
|
324
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">marks</span>.<span class="ruby-identifier">count</span>.<span class="ruby-identifier">positive?</span>
|
325
|
+
<span class="ruby-identifier">browse_linked</span>(<span class="ruby-identifier">sel</span>[<span class="ruby-value">0</span>])
|
326
|
+
<span class="ruby-keyword">else</span>
|
327
|
+
<span class="ruby-identifier">browse_bookmarks</span>(<span class="ruby-identifier">glob</span>)
|
328
|
+
<span class="ruby-keyword">end</span>
|
329
|
+
<span class="ruby-keyword">else</span>
|
330
|
+
<span class="ruby-identifier">open_linked</span>(<span class="ruby-identifier">sel</span>)
|
331
|
+
<span class="ruby-keyword">end</span>
|
332
|
+
<span class="ruby-keyword">end</span></pre>
|
333
|
+
</div>
|
334
|
+
</div>
|
335
|
+
|
336
|
+
|
337
|
+
</div>
|
338
|
+
|
339
|
+
<div id="method-i-browse_linked" class="method-detail ">
|
340
|
+
<div class="method-heading">
|
341
|
+
<span class="method-name">browse_linked</span><span
|
342
|
+
class="method-args">(url)</span>
|
343
|
+
<span class="method-click-advice">click to toggle source</span>
|
344
|
+
</div>
|
345
|
+
|
346
|
+
<div class="method-description">
|
347
|
+
<p>Select from a menu of available hooks and open using macOS `open`.</p>
|
348
|
+
|
349
|
+
<div class="method-source-code" id="browse_linked-source">
|
350
|
+
<pre><span class="ruby-comment"># File lib/hook/hookapp.rb, line 344</span>
|
351
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">browse_linked</span>(<span class="ruby-identifier">url</span>)
|
352
|
+
<span class="ruby-identifier">marks</span> = <span class="ruby-identifier">get_hooks</span>(<span class="ruby-identifier">url</span>)
|
353
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">marks</span>.<span class="ruby-identifier">empty?</span>
|
354
|
+
<span class="ruby-identifier">warn</span> <span class="ruby-node">"No hooks found for #{url}"</span>
|
355
|
+
<span class="ruby-keyword">else</span>
|
356
|
+
<span class="ruby-identifier">res</span> = <span class="ruby-identifier">select_hook</span>(<span class="ruby-identifier">marks</span>)
|
357
|
+
<span class="ruby-keyword">unless</span> <span class="ruby-identifier">res</span>.<span class="ruby-identifier">empty?</span>
|
358
|
+
<span class="ruby-identifier">res</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">mark</span><span class="ruby-operator">|</span> <span class="ruby-identifier">mark</span>[<span class="ruby-value">:path</span>] <span class="ruby-operator">?</span> <span class="ruby-identifier">act_on</span>(<span class="ruby-identifier">mark</span>[<span class="ruby-value">:path</span>]) <span class="ruby-operator">:</span> <span class="ruby-node">`open '#{mark[:url]}'`</span> }
|
359
|
+
<span class="ruby-keyword">end</span>
|
360
|
+
<span class="ruby-keyword">end</span>
|
280
361
|
<span class="ruby-keyword">end</span></pre>
|
281
362
|
</div>
|
282
363
|
</div>
|
@@ -317,7 +398,7 @@
|
|
317
398
|
<p>Copy all hooks from source file to target file</p>
|
318
399
|
|
319
400
|
<div class="method-source-code" id="clone_hooks-source">
|
320
|
-
<pre><span class="ruby-comment"># File lib/hook/hookapp.rb, line
|
401
|
+
<pre><span class="ruby-comment"># File lib/hook/hookapp.rb, line 380</span>
|
321
402
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">clone_hooks</span>(<span class="ruby-identifier">args</span>)
|
322
403
|
<span class="ruby-identifier">target</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">pop</span>.<span class="ruby-identifier">valid_hook</span>
|
323
404
|
<span class="ruby-identifier">source</span> = <span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">valid_hook</span>
|
@@ -381,7 +462,7 @@
|
|
381
462
|
|
382
463
|
|
383
464
|
<div class="method-source-code" id="decode-source">
|
384
|
-
<pre><span class="ruby-comment"># File lib/hook/hookapp.rb, line
|
465
|
+
<pre><span class="ruby-comment"># File lib/hook/hookapp.rb, line 566</span>
|
385
466
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">decode</span>(<span class="ruby-identifier">string</span>)
|
386
467
|
<span class="ruby-identifier">result</span> = <span class="ruby-node">`osascript <<'APPLESCRIPT'
|
387
468
|
tell application "Hook"
|
@@ -407,7 +488,7 @@ APPLESCRIPT`</span>.<span class="ruby-identifier">strip</span>
|
|
407
488
|
<p>Delete all hooked files/urls from target file</p>
|
408
489
|
|
409
490
|
<div class="method-source-code" id="delete_all_hooks-source">
|
410
|
-
<pre><span class="ruby-comment"># File lib/hook/hookapp.rb, line
|
491
|
+
<pre><span class="ruby-comment"># File lib/hook/hookapp.rb, line 403</span>
|
411
492
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">delete_all_hooks</span>(<span class="ruby-identifier">url</span>, <span class="ruby-value">force:</span> <span class="ruby-keyword">false</span>)
|
412
493
|
<span class="ruby-keyword">unless</span> <span class="ruby-identifier">force</span>
|
413
494
|
<span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">print</span> <span class="ruby-node">"Are you sure you want to delete ALL hooks from #{url} (y/N)? "</span>
|
@@ -445,7 +526,7 @@ APPLESCRIPT`</span>.<span class="ruby-identifier">strip</span>
|
|
445
526
|
<p>Delete hooks between two files/urls</p>
|
446
527
|
|
447
528
|
<div class="method-source-code" id="delete_hooks-source">
|
448
|
-
<pre><span class="ruby-comment"># File lib/hook/hookapp.rb, line
|
529
|
+
<pre><span class="ruby-comment"># File lib/hook/hookapp.rb, line 425</span>
|
449
530
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">delete_hooks</span>(<span class="ruby-identifier">args</span>, <span class="ruby-identifier">opts</span>)
|
450
531
|
<span class="ruby-identifier">urls</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">map</span>(<span class="ruby-operator">&</span><span class="ruby-value">:valid_hook</span>).<span class="ruby-identifier">delete_if</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">url</span><span class="ruby-operator">|</span> <span class="ruby-operator">!</span><span class="ruby-identifier">url</span> }
|
451
532
|
<span class="ruby-identifier">output</span> = []
|
@@ -491,7 +572,7 @@ APPLESCRIPT`</span>.<span class="ruby-identifier">strip</span>
|
|
491
572
|
|
492
573
|
|
493
574
|
<div class="method-source-code" id="encode-source">
|
494
|
-
<pre><span class="ruby-comment"># File lib/hook/hookapp.rb, line
|
575
|
+
<pre><span class="ruby-comment"># File lib/hook/hookapp.rb, line 557</span>
|
495
576
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">encode</span>(<span class="ruby-identifier">string</span>)
|
496
577
|
<span class="ruby-identifier">result</span> = <span class="ruby-node">`osascript <<'APPLESCRIPT'
|
497
578
|
tell application "Hook"
|
@@ -581,7 +662,7 @@ APPLESCRIPT`</span>.<span class="ruby-identifier">strip</span>.<span class="ruby
|
|
581
662
|
<p>Create bi-directional links between every file/url in the list of arguments</p>
|
582
663
|
|
583
664
|
<div class="method-source-code" id="link_all-source">
|
584
|
-
<pre><span class="ruby-comment"># File lib/hook/hookapp.rb, line
|
665
|
+
<pre><span class="ruby-comment"># File lib/hook/hookapp.rb, line 455</span>
|
585
666
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">link_all</span>(<span class="ruby-identifier">args</span>)
|
586
667
|
<span class="ruby-identifier">args</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">file</span><span class="ruby-operator">|</span>
|
587
668
|
<span class="ruby-identifier">source</span> = <span class="ruby-identifier">file</span>.<span class="ruby-identifier">valid_hook</span>
|
@@ -616,7 +697,7 @@ APPLESCRIPT`</span>.<span class="ruby-identifier">strip</span>.<span class="ruby
|
|
616
697
|
<p>Link 2 or more files/urls with bi-directional hooks.</p>
|
617
698
|
|
618
699
|
<div class="method-source-code" id="link_files-source">
|
619
|
-
<pre><span class="ruby-comment"># File lib/hook/hookapp.rb, line
|
700
|
+
<pre><span class="ruby-comment"># File lib/hook/hookapp.rb, line 357</span>
|
620
701
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">link_files</span>(<span class="ruby-identifier">args</span>)
|
621
702
|
<span class="ruby-identifier">target</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">pop</span>
|
622
703
|
<span class="ruby-identifier">target</span>.<span class="ruby-identifier">valid_hook!</span>
|
@@ -655,7 +736,7 @@ APPLESCRIPT`</span>.<span class="ruby-identifier">strip</span>.<span class="ruby
|
|
655
736
|
<p>Get a list of all hooks on a file/url.</p>
|
656
737
|
|
657
738
|
<div class="method-source-code" id="linked_bookmarks-source">
|
658
|
-
<pre><span class="ruby-comment"># File lib/hook/hookapp.rb, line
|
739
|
+
<pre><span class="ruby-comment"># File lib/hook/hookapp.rb, line 474</span>
|
659
740
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">linked_bookmarks</span>(<span class="ruby-identifier">args</span>, <span class="ruby-identifier">opts</span>)
|
660
741
|
<span class="ruby-identifier">result</span> = []
|
661
742
|
|
@@ -718,7 +799,7 @@ APPLESCRIPT`</span>.<span class="ruby-identifier">strip</span>.<span class="ruby
|
|
718
799
|
<p>Open the <a href="Hook.html"><code>Hook</code></a> GUI for browsing/performing actions on a file or url</p>
|
719
800
|
|
720
801
|
<div class="method-source-code" id="open_gui-source">
|
721
|
-
<pre><span class="ruby-comment"># File lib/hook/hookapp.rb, line
|
802
|
+
<pre><span class="ruby-comment"># File lib/hook/hookapp.rb, line 317</span>
|
722
803
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">open_gui</span>(<span class="ruby-identifier">url</span>)
|
723
804
|
<span class="ruby-identifier">result</span> = <span class="ruby-node">`osascript <<'APPLESCRIPT'
|
724
805
|
tell application "Hook"
|
@@ -750,18 +831,14 @@ APPLESCRIPT`</span>.<span class="ruby-identifier">strip</span>.<span class="ruby
|
|
750
831
|
<p>Select from a menu of available hooks and open using macOS `open`.</p>
|
751
832
|
|
752
833
|
<div class="method-source-code" id="open_linked-source">
|
753
|
-
<pre><span class="ruby-comment"># File lib/hook/hookapp.rb, line
|
834
|
+
<pre><span class="ruby-comment"># File lib/hook/hookapp.rb, line 333</span>
|
754
835
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">open_linked</span>(<span class="ruby-identifier">url</span>)
|
755
836
|
<span class="ruby-identifier">marks</span> = <span class="ruby-identifier">get_hooks</span>(<span class="ruby-identifier">url</span>)
|
756
837
|
<span class="ruby-keyword">if</span> <span class="ruby-identifier">marks</span>.<span class="ruby-identifier">empty?</span>
|
757
838
|
<span class="ruby-identifier">warn</span> <span class="ruby-node">"No hooks found for #{url}"</span>
|
758
839
|
<span class="ruby-keyword">else</span>
|
759
840
|
<span class="ruby-identifier">res</span> = <span class="ruby-identifier">select_hook</span>(<span class="ruby-identifier">marks</span>)
|
760
|
-
<span class="ruby-keyword">unless</span> <span class="ruby-identifier">res</span>.<span class="ruby-identifier">empty?</span>
|
761
|
-
<span class="ruby-identifier">res</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">mark</span><span class="ruby-operator">|</span>
|
762
|
-
<span class="ruby-node">`open '#{mark[:url]}'`</span>
|
763
|
-
}
|
764
|
-
<span class="ruby-keyword">end</span>
|
841
|
+
<span class="ruby-identifier">res</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">mark</span><span class="ruby-operator">|</span> <span class="ruby-node">`open '#{mark[:url]}'`</span> } <span class="ruby-keyword">unless</span> <span class="ruby-identifier">res</span>.<span class="ruby-identifier">empty?</span>
|
765
842
|
<span class="ruby-keyword">end</span>
|
766
843
|
<span class="ruby-keyword">end</span></pre>
|
767
844
|
</div>
|
@@ -781,7 +858,7 @@ APPLESCRIPT`</span>.<span class="ruby-identifier">strip</span>.<span class="ruby
|
|
781
858
|
<p>Output an array of hooks in the given format.</p>
|
782
859
|
|
783
860
|
<div class="method-source-code" id="output_array-source">
|
784
|
-
<pre><span class="ruby-comment"># File lib/hook/hookapp.rb, line
|
861
|
+
<pre><span class="ruby-comment"># File lib/hook/hookapp.rb, line 521</span>
|
785
862
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">output_array</span>(<span class="ruby-identifier">hooks_arr</span>, <span class="ruby-identifier">opts</span>)
|
786
863
|
<span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">hooks_arr</span>.<span class="ruby-identifier">empty?</span>
|
787
864
|
<span class="ruby-identifier">hooks_arr</span>.<span class="ruby-identifier">reject!</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">h</span><span class="ruby-operator">|</span> <span class="ruby-identifier">h</span>[<span class="ruby-value">:path</span>].<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">h</span>[<span class="ruby-value">:path</span>] <span class="ruby-operator">==</span> <span class="ruby-string">''</span> } <span class="ruby-keyword">if</span> <span class="ruby-identifier">opts</span>[<span class="ruby-value">:files_only</span>]
|
@@ -953,7 +1030,7 @@ APPLESCRIPT`</span>.<span class="ruby-identifier">strip</span>.<span class="ruby
|
|
953
1030
|
|
954
1031
|
<span class="ruby-comment"># marks[sel - 1]</span>
|
955
1032
|
|
956
|
-
<span class="ruby-identifier">options</span> = <span class="ruby-identifier">marks</span>.<span class="ruby-identifier">map</span>
|
1033
|
+
<span class="ruby-identifier">options</span> = <span class="ruby-identifier">marks</span>.<span class="ruby-identifier">map</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">mark</span><span class="ruby-operator">|</span>
|
957
1034
|
<span class="ruby-keyword">if</span> <span class="ruby-identifier">mark</span>[<span class="ruby-value">:name</span>]
|
958
1035
|
<span class="ruby-identifier">id</span> = <span class="ruby-identifier">mark</span>[<span class="ruby-value">:name</span>]
|
959
1036
|
<span class="ruby-keyword">elsif</span> <span class="ruby-identifier">mark</span>[<span class="ruby-value">:path</span>]
|
@@ -969,15 +1046,17 @@ APPLESCRIPT`</span>.<span class="ruby-identifier">strip</span>.<span class="ruby
|
|
969
1046
|
<span class="ruby-keyword">elsif</span> <span class="ruby-identifier">mark</span>[<span class="ruby-value">:url</span>]
|
970
1047
|
<span class="ruby-identifier">url</span> = <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">mark</span>[<span class="ruby-value">:url</span>])
|
971
1048
|
<span class="ruby-identifier">id</span> = <span class="ruby-identifier">mark</span>[<span class="ruby-value">:url</span>]
|
972
|
-
<span class="ruby-identifier">loc</span> = <span class="ruby-
|
1049
|
+
<span class="ruby-identifier">loc</span> = <span class="ruby-node">"#{url.scheme} - #{url.hostname}"</span>
|
973
1050
|
<span class="ruby-keyword">else</span>
|
974
|
-
<span class="ruby-identifier">loc</span> = <span class="ruby-string"
|
1051
|
+
<span class="ruby-identifier">loc</span> = <span class="ruby-string">''</span>
|
975
1052
|
<span class="ruby-keyword">end</span>
|
976
1053
|
|
977
1054
|
<span class="ruby-node">"#{id}\t#{mark[:path]}\t#{mark[:url]}\t#{loc}"</span>
|
978
|
-
|
1055
|
+
<span class="ruby-keyword">end</span>
|
1056
|
+
|
1057
|
+
<span class="ruby-identifier">options</span>.<span class="ruby-identifier">delete_if</span>(<span class="ruby-operator">&</span><span class="ruby-value">:!</span>)
|
979
1058
|
|
980
|
-
<span class="ruby-identifier">raise</span> <span class="ruby-string"
|
1059
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-string">'Error processing available hooks'</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">empty?</span>
|
981
1060
|
|
982
1061
|
<span class="ruby-identifier">args</span> = [<span class="ruby-string">'--layout=reverse-list'</span>,
|
983
1062
|
<span class="ruby-string">'--header="esc: cancel, tab: multi-select, ctrl-a: select all, return: open"'</span>,
|
data/html/README_rdoc.html
CHANGED
@@ -133,7 +133,7 @@
|
|
133
133
|
|
134
134
|
<p>This gem includes a `hook` binary that allows interaction with the features of Hook.app.</p>
|
135
135
|
|
136
|
-
<p>v2.0.
|
136
|
+
<p>v2.0.15</p>
|
137
137
|
|
138
138
|
<h3 id="label-Global+Options">Global Options<span><a href="#label-Global+Options">¶</a> <a href="#top">↑</a></span></h3>
|
139
139
|
|
data/html/created.rid
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
|
1
|
+
Wed, 20 Jul 2022 08:04:13 -0500
|
2
2
|
README.rdoc Tue, 07 Jul 2020 16:57:07 -0500
|
3
3
|
lib/hook.rb Thu, 26 May 2022 08:20:27 -0500
|
4
|
-
lib/hook/hookapp.rb
|
4
|
+
lib/hook/hookapp.rb Wed, 20 Jul 2022 08:01:12 -0500
|
5
5
|
lib/hook/hooker.rb Sun, 31 Oct 2021 07:54:46 -0500
|
6
6
|
lib/hook/markdown_document_listener.rb Sun, 26 Sep 2021 07:45:59 -0500
|
7
7
|
lib/hook/prompt.rb Thu, 26 May 2022 08:20:13 -0500
|
8
8
|
lib/hook/string.rb Sun, 31 Oct 2021 07:03:15 -0500
|
9
|
-
lib/hook/version.rb
|
9
|
+
lib/hook/version.rb Wed, 20 Jul 2022 08:03:21 -0500
|
10
10
|
bin/hook Tue, 19 Jul 2022 14:11:16 -0500
|
data/html/index.html
CHANGED
@@ -99,7 +99,7 @@
|
|
99
99
|
|
100
100
|
<p>This gem includes a `hook` binary that allows interaction with the features of Hook.app.</p>
|
101
101
|
|
102
|
-
<p>v2.0.
|
102
|
+
<p>v2.0.15</p>
|
103
103
|
|
104
104
|
<h3 id="label-Global+Options">Global Options<span><a href="#label-Global+Options">¶</a> <a href="#top">↑</a></span></h3>
|
105
105
|
|
data/html/js/search_index.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
var search_data = {"index":{"searchIndex":["app","gli","commands","doc","markdowndocumentlistener","hook","prompt","promptfzf","promptstd","hookapp","hooker","string","all_bookmarks()","beginning()","bookmark_for()","bookmark_from_app()","browse_bookmarks()","cap()","cap!()","clear_screen()","clip()","clip_bookmark()","clone_hooks()","command()","commands()","copy_bookmark()","decode()","default_command()","delete_all_hooks()","delete_hooks()","encode()","end_command()","end_commands()","end_options()","ending()","escape_quotes()","flag()","format_regex()","fzf()","get_hooks()","install_fzf()","link_all()","link_files()","linked_bookmarks()","new()","new()","nil_if_missing()","open_gui()","open_linked()","options()","output_array()","program_desc()","program_long_desc()","restore_std()","search_bookmarks()","search_name()","search_path_or_address()","select_hook()","silence_std()","split_hook()","split_hooks()","switch()","uninstall_fzf()","valid_hook()","valid_hook!()","validate_format()","version()","which_fzf()","readme"],"longSearchIndex":["app","gli","gli::commands","gli::commands::doc","gli::commands::markdowndocumentlistener","hook","hook::prompt","hook::promptfzf","hook::promptstd","hookapp","hooker","string","hookapp#all_bookmarks()","gli::commands::markdowndocumentlistener#beginning()","hookapp#bookmark_for()","hookapp#bookmark_from_app()","hookapp#browse_bookmarks()","string#cap()","string#cap!()","hook::promptstd#clear_screen()","string#clip()","hookapp#clip_bookmark()","hookapp#clone_hooks()","gli::commands::markdowndocumentlistener#command()","gli::commands::markdowndocumentlistener#commands()","hookapp#copy_bookmark()","hookapp#decode()","gli::commands::markdowndocumentlistener#default_command()","hookapp#delete_all_hooks()","hookapp#delete_hooks()","hookapp#encode()","gli::commands::markdowndocumentlistener#end_command()","gli::commands::markdowndocumentlistener#end_commands()","gli::commands::markdowndocumentlistener#end_options()","gli::commands::markdowndocumentlistener#ending()","string#escape_quotes()","gli::commands::markdowndocumentlistener#flag()","hookapp#format_regex()","hook::promptfzf#fzf()","hookapp#get_hooks()","hook::promptfzf#install_fzf()","hookapp#link_all()","hookapp#link_files()","hookapp#linked_bookmarks()","gli::commands::markdowndocumentlistener::new()","hooker::new()","string#nil_if_missing()","hookapp#open_gui()","hookapp#open_linked()","gli::commands::markdowndocumentlistener#options()","hookapp#output_array()","gli::commands::markdowndocumentlistener#program_desc()","gli::commands::markdowndocumentlistener#program_long_desc()","hook::promptstd#restore_std()","hookapp#search_bookmarks()","hookapp#search_name()","hookapp#search_path_or_address()","hookapp#select_hook()","hook::promptstd#silence_std()","string#split_hook()","string#split_hooks()","gli::commands::markdowndocumentlistener#switch()","hook::promptfzf#uninstall_fzf()","string#valid_hook()","string#valid_hook!()","hookapp#validate_format()","gli::commands::markdowndocumentlistener#version()","hook::promptfzf#which_fzf()",""],"info":[["App","","App.html","","<p>Main class for GLI app\n"],["GLI","","GLI.html","",""],["GLI::Commands","","GLI/Commands.html","",""],["GLI::Commands::Doc","","GLI/Commands/Doc.html","",""],["GLI::Commands::MarkdownDocumentListener","","GLI/Commands/MarkdownDocumentListener.html","","<p>DocumentListener class for GLI documentation generator\n"],["Hook","","Hook.html","",""],["Hook::Prompt","","Hook/Prompt.html","",""],["Hook::PromptFZF","","Hook/PromptFZF.html","","<p>Methods for working installing/using FuzzyFileFinder\n"],["Hook::PromptSTD","","Hook/PromptSTD.html","",""],["HookApp","","HookApp.html","","<p>Hook.app functions\n"],["Hooker","","Hooker.html","","<p>Hook.app CLI interface\n"],["String","","String.html","","<p>String helpers\n"],["all_bookmarks","HookApp","HookApp.html#method-i-all_bookmarks","()","<p>Get all known bookmarks. Return array of bookmark hashes.\n"],["beginning","GLI::Commands::MarkdownDocumentListener","GLI/Commands/MarkdownDocumentListener.html#method-i-beginning","()",""],["bookmark_for","HookApp","HookApp.html#method-i-bookmark_for","(url)","<p>Get a Hook bookmark for file or URL. Return bookmark hash.\n"],["bookmark_from_app","HookApp","HookApp.html#method-i-bookmark_from_app","(app, opts)","<p>Get a bookmark from the foreground document of specified app.\n"],["browse_bookmarks","HookApp","HookApp.html#method-i-browse_bookmarks","(glob)",""],["cap","String","String.html#method-i-cap","()","<p>Capitalize only if no uppercase\n"],["cap!","String","String.html#method-i-cap-21","()",""],["clear_screen","Hook::PromptSTD","Hook/PromptSTD.html#method-i-clear_screen","(msg = nil)","<p>Clear the terminal screen\n"],["clip","String","String.html#method-i-clip","()",""],["clip_bookmark","HookApp","HookApp.html#method-i-clip_bookmark","(url, opts)","<p>Create a bookmark for specified file/url and copy to the clipboard.\n"],["clone_hooks","HookApp","HookApp.html#method-i-clone_hooks","(args)","<p>Copy all hooks from source file to target file\n"],["command","GLI::Commands::MarkdownDocumentListener","GLI/Commands/MarkdownDocumentListener.html#method-i-command","(name, aliases, desc, long_desc, arg_name, arg_options)","<p>Gives you a command in the current context and creates a new context of this command\n"],["commands","GLI::Commands::MarkdownDocumentListener","GLI/Commands/MarkdownDocumentListener.html#method-i-commands","()",""],["copy_bookmark","HookApp","HookApp.html#method-i-copy_bookmark","(title, url, opts)","<p>Create a bookmark from specified title and url and copy to the clipboard.\n"],["decode","HookApp","HookApp.html#method-i-decode","(string)",""],["default_command","GLI::Commands::MarkdownDocumentListener","GLI/Commands/MarkdownDocumentListener.html#method-i-default_command","(name)","<p>Gives you the name of the current command in the current context\n"],["delete_all_hooks","HookApp","HookApp.html#method-i-delete_all_hooks","(url, force: false)","<p>Delete all hooked files/urls from target file\n"],["delete_hooks","HookApp","HookApp.html#method-i-delete_hooks","(args, opts)","<p>Delete hooks between two files/urls\n"],["encode","HookApp","HookApp.html#method-i-encode","(string)",""],["end_command","GLI::Commands::MarkdownDocumentListener","GLI/Commands/MarkdownDocumentListener.html#method-i-end_command","(_name)","<p>Ends a command, and “pops” you back up one context\n"],["end_commands","GLI::Commands::MarkdownDocumentListener","GLI/Commands/MarkdownDocumentListener.html#method-i-end_commands","()",""],["end_options","GLI::Commands::MarkdownDocumentListener","GLI/Commands/MarkdownDocumentListener.html#method-i-end_options","()",""],["ending","GLI::Commands::MarkdownDocumentListener","GLI/Commands/MarkdownDocumentListener.html#method-i-ending","()","<p>Called when processing has completed\n"],["escape_quotes","String","String.html#method-i-escape_quotes","()",""],["flag","GLI::Commands::MarkdownDocumentListener","GLI/Commands/MarkdownDocumentListener.html#method-i-flag","(name, aliases, desc, long_desc, default_value, arg_name, must_match, _type)","<p>Gives you a flag in the current context\n"],["format_regex","HookApp","HookApp.html#method-i-format_regex","(options)","<p>Create a single regex for validation of an array by first char or full match.\n"],["fzf","Hook::PromptFZF","Hook/PromptFZF.html#method-i-fzf","()","<p>Get path to fzf binary, installing if needed\n<p>@return [String] Path to fzf binary\n"],["get_hooks","HookApp","HookApp.html#method-i-get_hooks","(url)","<p>Get bookmarks hooked to file or URL. Return array of bookmark hashes.\n"],["install_fzf","Hook::PromptFZF","Hook/PromptFZF.html#method-i-install_fzf","(force: false)","<p>Install fzf on the current system. Installs to a subdirectory of the gem\n<p>@param force [Boolean] …\n"],["link_all","HookApp","HookApp.html#method-i-link_all","(args)","<p>Create bi-directional links between every file/url in the list of arguments\n"],["link_files","HookApp","HookApp.html#method-i-link_files","(args)","<p>Link 2 or more files/urls with bi-directional hooks.\n"],["linked_bookmarks","HookApp","HookApp.html#method-i-linked_bookmarks","(args, opts)","<p>Get a list of all hooks on a file/url.\n"],["new","GLI::Commands::MarkdownDocumentListener","GLI/Commands/MarkdownDocumentListener.html#method-c-new","(_global_options, _options, _arguments, app)",""],["new","Hooker","Hooker.html#method-c-new","()",""],["nil_if_missing","String","String.html#method-i-nil_if_missing","()",""],["open_gui","HookApp","HookApp.html#method-i-open_gui","(url)","<p>Open the Hook GUI for browsing/performing actions on a file or url\n"],["open_linked","HookApp","HookApp.html#method-i-open_linked","(url)","<p>Select from a menu of available hooks and open using macOS `open`.\n"],["options","GLI::Commands::MarkdownDocumentListener","GLI/Commands/MarkdownDocumentListener.html#method-i-options","()",""],["output_array","HookApp","HookApp.html#method-i-output_array","(hooks_arr, opts)","<p>Output an array of hooks in the given format.\n"],["program_desc","GLI::Commands::MarkdownDocumentListener","GLI/Commands/MarkdownDocumentListener.html#method-i-program_desc","(desc)","<p>Gives you the program description\n"],["program_long_desc","GLI::Commands::MarkdownDocumentListener","GLI/Commands/MarkdownDocumentListener.html#method-i-program_long_desc","(desc)",""],["restore_std","Hook::PromptSTD","Hook/PromptSTD.html#method-i-restore_std","()","<p>Restore silenced STDOUT and STDERR\n"],["search_bookmarks","HookApp","HookApp.html#method-i-search_bookmarks","(search, opts)","<p>Search bookmarks, using both names and addresses unless options contain “:names_only”. Return …\n"],["search_name","HookApp","HookApp.html#method-i-search_name","(search)","<p>Search boomark names/titles. Return array of bookmark hashes.\n"],["search_path_or_address","HookApp","HookApp.html#method-i-search_path_or_address","(search)","<p>Search bookmark paths and addresses. Return array of bookmark hashes.\n"],["select_hook","HookApp","HookApp.html#method-i-select_hook","(marks)","<p>Generate a menu of available hooks for selecting one or more hooks to operate on. Revamped to use `fzf`, …\n"],["silence_std","Hook::PromptSTD","Hook/PromptSTD.html#method-i-silence_std","(file = '/dev/null')","<p>Redirect STDOUT and STDERR to /dev/null or file\n<p>@param file [String] a file path to redirect to …\n"],["split_hook","String","String.html#method-i-split_hook","()",""],["split_hooks","String","String.html#method-i-split_hooks","()",""],["switch","GLI::Commands::MarkdownDocumentListener","GLI/Commands/MarkdownDocumentListener.html#method-i-switch","(name, aliases, desc, long_desc, negatable)","<p>Gives you a switch in the current context\n"],["uninstall_fzf","Hook::PromptFZF","Hook/PromptFZF.html#method-i-uninstall_fzf","()","<p>Remove fzf binary\n"],["valid_hook","String","String.html#method-i-valid_hook","()",""],["valid_hook!","String","String.html#method-i-valid_hook-21","()",""],["validate_format","HookApp","HookApp.html#method-i-validate_format","(fmt, options)","<p>Check if format fully matches or matches the first character of available options. Return full valid …\n"],["version","GLI::Commands::MarkdownDocumentListener","GLI/Commands/MarkdownDocumentListener.html#method-i-version","(version)","<p>Gives you the program version\n"],["which_fzf","Hook::PromptFZF","Hook/PromptFZF.html#method-i-which_fzf","()","<p>Return the path to the fzf binary\n<p>@return [String] Path to fzf\n"],["README","","README_rdoc.html","","<p>hookapp\n<p>A CLI for Hook.app on macOS.\n<p>hook - CLI interface for Hook.app (macOS)\n"]]}}
|
1
|
+
var search_data = {"index":{"searchIndex":["app","gli","commands","doc","markdowndocumentlistener","hook","prompt","promptfzf","promptstd","hookapp","hooker","string","act_on()","all_bookmarks()","beginning()","bookmark_for()","bookmark_from_app()","browse_bookmarks()","browse_linked()","cap()","cap!()","clear_screen()","clip()","clip_bookmark()","clone_hooks()","command()","commands()","copy_bookmark()","decode()","default_command()","delete_all_hooks()","delete_hooks()","encode()","end_command()","end_commands()","end_options()","ending()","escape_quotes()","flag()","format_regex()","fzf()","get_hooks()","install_fzf()","link_all()","link_files()","linked_bookmarks()","new()","new()","nil_if_missing()","open_gui()","open_linked()","options()","output_array()","program_desc()","program_long_desc()","restore_std()","search_bookmarks()","search_name()","search_path_or_address()","select_hook()","silence_std()","split_hook()","split_hooks()","switch()","uninstall_fzf()","valid_hook()","valid_hook!()","validate_format()","version()","which_fzf()","readme"],"longSearchIndex":["app","gli","gli::commands","gli::commands::doc","gli::commands::markdowndocumentlistener","hook","hook::prompt","hook::promptfzf","hook::promptstd","hookapp","hooker","string","hookapp#act_on()","hookapp#all_bookmarks()","gli::commands::markdowndocumentlistener#beginning()","hookapp#bookmark_for()","hookapp#bookmark_from_app()","hookapp#browse_bookmarks()","hookapp#browse_linked()","string#cap()","string#cap!()","hook::promptstd#clear_screen()","string#clip()","hookapp#clip_bookmark()","hookapp#clone_hooks()","gli::commands::markdowndocumentlistener#command()","gli::commands::markdowndocumentlistener#commands()","hookapp#copy_bookmark()","hookapp#decode()","gli::commands::markdowndocumentlistener#default_command()","hookapp#delete_all_hooks()","hookapp#delete_hooks()","hookapp#encode()","gli::commands::markdowndocumentlistener#end_command()","gli::commands::markdowndocumentlistener#end_commands()","gli::commands::markdowndocumentlistener#end_options()","gli::commands::markdowndocumentlistener#ending()","string#escape_quotes()","gli::commands::markdowndocumentlistener#flag()","hookapp#format_regex()","hook::promptfzf#fzf()","hookapp#get_hooks()","hook::promptfzf#install_fzf()","hookapp#link_all()","hookapp#link_files()","hookapp#linked_bookmarks()","gli::commands::markdowndocumentlistener::new()","hooker::new()","string#nil_if_missing()","hookapp#open_gui()","hookapp#open_linked()","gli::commands::markdowndocumentlistener#options()","hookapp#output_array()","gli::commands::markdowndocumentlistener#program_desc()","gli::commands::markdowndocumentlistener#program_long_desc()","hook::promptstd#restore_std()","hookapp#search_bookmarks()","hookapp#search_name()","hookapp#search_path_or_address()","hookapp#select_hook()","hook::promptstd#silence_std()","string#split_hook()","string#split_hooks()","gli::commands::markdowndocumentlistener#switch()","hook::promptfzf#uninstall_fzf()","string#valid_hook()","string#valid_hook!()","hookapp#validate_format()","gli::commands::markdowndocumentlistener#version()","hook::promptfzf#which_fzf()",""],"info":[["App","","App.html","","<p>Main class for GLI app\n"],["GLI","","GLI.html","",""],["GLI::Commands","","GLI/Commands.html","",""],["GLI::Commands::Doc","","GLI/Commands/Doc.html","",""],["GLI::Commands::MarkdownDocumentListener","","GLI/Commands/MarkdownDocumentListener.html","","<p>DocumentListener class for GLI documentation generator\n"],["Hook","","Hook.html","",""],["Hook::Prompt","","Hook/Prompt.html","",""],["Hook::PromptFZF","","Hook/PromptFZF.html","","<p>Methods for working installing/using FuzzyFileFinder\n"],["Hook::PromptSTD","","Hook/PromptSTD.html","",""],["HookApp","","HookApp.html","","<p>Hook.app functions\n"],["Hooker","","Hooker.html","","<p>Hook.app CLI interface\n"],["String","","String.html","","<p>String helpers\n"],["act_on","HookApp","HookApp.html#method-i-act_on","(url)",""],["all_bookmarks","HookApp","HookApp.html#method-i-all_bookmarks","()","<p>Get all known bookmarks. Return array of bookmark hashes.\n"],["beginning","GLI::Commands::MarkdownDocumentListener","GLI/Commands/MarkdownDocumentListener.html#method-i-beginning","()",""],["bookmark_for","HookApp","HookApp.html#method-i-bookmark_for","(url)","<p>Get a Hook bookmark for file or URL. Return bookmark hash.\n"],["bookmark_from_app","HookApp","HookApp.html#method-i-bookmark_from_app","(app, opts)","<p>Get a bookmark from the foreground document of specified app.\n"],["browse_bookmarks","HookApp","HookApp.html#method-i-browse_bookmarks","(glob)",""],["browse_linked","HookApp","HookApp.html#method-i-browse_linked","(url)","<p>Select from a menu of available hooks and open using macOS `open`.\n"],["cap","String","String.html#method-i-cap","()","<p>Capitalize only if no uppercase\n"],["cap!","String","String.html#method-i-cap-21","()",""],["clear_screen","Hook::PromptSTD","Hook/PromptSTD.html#method-i-clear_screen","(msg = nil)","<p>Clear the terminal screen\n"],["clip","String","String.html#method-i-clip","()",""],["clip_bookmark","HookApp","HookApp.html#method-i-clip_bookmark","(url, opts)","<p>Create a bookmark for specified file/url and copy to the clipboard.\n"],["clone_hooks","HookApp","HookApp.html#method-i-clone_hooks","(args)","<p>Copy all hooks from source file to target file\n"],["command","GLI::Commands::MarkdownDocumentListener","GLI/Commands/MarkdownDocumentListener.html#method-i-command","(name, aliases, desc, long_desc, arg_name, arg_options)","<p>Gives you a command in the current context and creates a new context of this command\n"],["commands","GLI::Commands::MarkdownDocumentListener","GLI/Commands/MarkdownDocumentListener.html#method-i-commands","()",""],["copy_bookmark","HookApp","HookApp.html#method-i-copy_bookmark","(title, url, opts)","<p>Create a bookmark from specified title and url and copy to the clipboard.\n"],["decode","HookApp","HookApp.html#method-i-decode","(string)",""],["default_command","GLI::Commands::MarkdownDocumentListener","GLI/Commands/MarkdownDocumentListener.html#method-i-default_command","(name)","<p>Gives you the name of the current command in the current context\n"],["delete_all_hooks","HookApp","HookApp.html#method-i-delete_all_hooks","(url, force: false)","<p>Delete all hooked files/urls from target file\n"],["delete_hooks","HookApp","HookApp.html#method-i-delete_hooks","(args, opts)","<p>Delete hooks between two files/urls\n"],["encode","HookApp","HookApp.html#method-i-encode","(string)",""],["end_command","GLI::Commands::MarkdownDocumentListener","GLI/Commands/MarkdownDocumentListener.html#method-i-end_command","(_name)","<p>Ends a command, and “pops” you back up one context\n"],["end_commands","GLI::Commands::MarkdownDocumentListener","GLI/Commands/MarkdownDocumentListener.html#method-i-end_commands","()",""],["end_options","GLI::Commands::MarkdownDocumentListener","GLI/Commands/MarkdownDocumentListener.html#method-i-end_options","()",""],["ending","GLI::Commands::MarkdownDocumentListener","GLI/Commands/MarkdownDocumentListener.html#method-i-ending","()","<p>Called when processing has completed\n"],["escape_quotes","String","String.html#method-i-escape_quotes","()",""],["flag","GLI::Commands::MarkdownDocumentListener","GLI/Commands/MarkdownDocumentListener.html#method-i-flag","(name, aliases, desc, long_desc, default_value, arg_name, must_match, _type)","<p>Gives you a flag in the current context\n"],["format_regex","HookApp","HookApp.html#method-i-format_regex","(options)","<p>Create a single regex for validation of an array by first char or full match.\n"],["fzf","Hook::PromptFZF","Hook/PromptFZF.html#method-i-fzf","()","<p>Get path to fzf binary, installing if needed\n<p>@return [String] Path to fzf binary\n"],["get_hooks","HookApp","HookApp.html#method-i-get_hooks","(url)","<p>Get bookmarks hooked to file or URL. Return array of bookmark hashes.\n"],["install_fzf","Hook::PromptFZF","Hook/PromptFZF.html#method-i-install_fzf","(force: false)","<p>Install fzf on the current system. Installs to a subdirectory of the gem\n<p>@param force [Boolean] …\n"],["link_all","HookApp","HookApp.html#method-i-link_all","(args)","<p>Create bi-directional links between every file/url in the list of arguments\n"],["link_files","HookApp","HookApp.html#method-i-link_files","(args)","<p>Link 2 or more files/urls with bi-directional hooks.\n"],["linked_bookmarks","HookApp","HookApp.html#method-i-linked_bookmarks","(args, opts)","<p>Get a list of all hooks on a file/url.\n"],["new","GLI::Commands::MarkdownDocumentListener","GLI/Commands/MarkdownDocumentListener.html#method-c-new","(_global_options, _options, _arguments, app)",""],["new","Hooker","Hooker.html#method-c-new","()",""],["nil_if_missing","String","String.html#method-i-nil_if_missing","()",""],["open_gui","HookApp","HookApp.html#method-i-open_gui","(url)","<p>Open the Hook GUI for browsing/performing actions on a file or url\n"],["open_linked","HookApp","HookApp.html#method-i-open_linked","(url)","<p>Select from a menu of available hooks and open using macOS `open`.\n"],["options","GLI::Commands::MarkdownDocumentListener","GLI/Commands/MarkdownDocumentListener.html#method-i-options","()",""],["output_array","HookApp","HookApp.html#method-i-output_array","(hooks_arr, opts)","<p>Output an array of hooks in the given format.\n"],["program_desc","GLI::Commands::MarkdownDocumentListener","GLI/Commands/MarkdownDocumentListener.html#method-i-program_desc","(desc)","<p>Gives you the program description\n"],["program_long_desc","GLI::Commands::MarkdownDocumentListener","GLI/Commands/MarkdownDocumentListener.html#method-i-program_long_desc","(desc)",""],["restore_std","Hook::PromptSTD","Hook/PromptSTD.html#method-i-restore_std","()","<p>Restore silenced STDOUT and STDERR\n"],["search_bookmarks","HookApp","HookApp.html#method-i-search_bookmarks","(search, opts)","<p>Search bookmarks, using both names and addresses unless options contain “:names_only”. Return …\n"],["search_name","HookApp","HookApp.html#method-i-search_name","(search)","<p>Search boomark names/titles. Return array of bookmark hashes.\n"],["search_path_or_address","HookApp","HookApp.html#method-i-search_path_or_address","(search)","<p>Search bookmark paths and addresses. Return array of bookmark hashes.\n"],["select_hook","HookApp","HookApp.html#method-i-select_hook","(marks)","<p>Generate a menu of available hooks for selecting one or more hooks to operate on. Revamped to use `fzf`, …\n"],["silence_std","Hook::PromptSTD","Hook/PromptSTD.html#method-i-silence_std","(file = '/dev/null')","<p>Redirect STDOUT and STDERR to /dev/null or file\n<p>@param file [String] a file path to redirect to …\n"],["split_hook","String","String.html#method-i-split_hook","()",""],["split_hooks","String","String.html#method-i-split_hooks","()",""],["switch","GLI::Commands::MarkdownDocumentListener","GLI/Commands/MarkdownDocumentListener.html#method-i-switch","(name, aliases, desc, long_desc, negatable)","<p>Gives you a switch in the current context\n"],["uninstall_fzf","Hook::PromptFZF","Hook/PromptFZF.html#method-i-uninstall_fzf","()","<p>Remove fzf binary\n"],["valid_hook","String","String.html#method-i-valid_hook","()",""],["valid_hook!","String","String.html#method-i-valid_hook-21","()",""],["validate_format","HookApp","HookApp.html#method-i-validate_format","(fmt, options)","<p>Check if format fully matches or matches the first character of available options. Return full valid …\n"],["version","GLI::Commands::MarkdownDocumentListener","GLI/Commands/MarkdownDocumentListener.html#method-i-version","(version)","<p>Gives you the program version\n"],["which_fzf","Hook::PromptFZF","Hook/PromptFZF.html#method-i-which_fzf","()","<p>Return the path to the fzf binary\n<p>@return [String] Path to fzf\n"],["README","","README_rdoc.html","","<p>hookapp\n<p>A CLI for Hook.app on macOS.\n<p>hook - CLI interface for Hook.app (macOS)\n"]]}}
|
data/html/js/search_index.js.gz
CHANGED
Binary file
|
data/html/table_of_contents.html
CHANGED
@@ -134,6 +134,11 @@
|
|
134
134
|
—
|
135
135
|
<span class="container">Hooker</span>
|
136
136
|
|
137
|
+
<li class="method">
|
138
|
+
<a href="HookApp.html#method-i-act_on">#act_on</a>
|
139
|
+
—
|
140
|
+
<span class="container">HookApp</span>
|
141
|
+
|
137
142
|
<li class="method">
|
138
143
|
<a href="HookApp.html#method-i-all_bookmarks">#all_bookmarks</a>
|
139
144
|
—
|
@@ -159,6 +164,11 @@
|
|
159
164
|
—
|
160
165
|
<span class="container">HookApp</span>
|
161
166
|
|
167
|
+
<li class="method">
|
168
|
+
<a href="HookApp.html#method-i-browse_linked">#browse_linked</a>
|
169
|
+
—
|
170
|
+
<span class="container">HookApp</span>
|
171
|
+
|
162
172
|
<li class="method">
|
163
173
|
<a href="String.html#method-i-cap">#cap</a>
|
164
174
|
—
|
data/lib/hook/hookapp.rb
CHANGED
@@ -208,7 +208,7 @@ class HookApp
|
|
208
208
|
|
209
209
|
# marks[sel - 1]
|
210
210
|
|
211
|
-
options = marks.map
|
211
|
+
options = marks.map do |mark|
|
212
212
|
if mark[:name]
|
213
213
|
id = mark[:name]
|
214
214
|
elsif mark[:path]
|
@@ -224,15 +224,17 @@ class HookApp
|
|
224
224
|
elsif mark[:url]
|
225
225
|
url = URI.parse(mark[:url])
|
226
226
|
id = mark[:url]
|
227
|
-
loc = url.scheme
|
227
|
+
loc = "#{url.scheme} - #{url.hostname}"
|
228
228
|
else
|
229
|
-
loc =
|
229
|
+
loc = ''
|
230
230
|
end
|
231
231
|
|
232
232
|
"#{id}\t#{mark[:path]}\t#{mark[:url]}\t#{loc}"
|
233
|
-
|
233
|
+
end
|
234
|
+
|
235
|
+
options.delete_if(&:!)
|
234
236
|
|
235
|
-
raise
|
237
|
+
raise 'Error processing available hooks' if options.empty?
|
236
238
|
|
237
239
|
args = ['--layout=reverse-list',
|
238
240
|
'--header="esc: cancel, tab: multi-select, ctrl-a: select all, return: open"',
|
@@ -256,26 +258,59 @@ class HookApp
|
|
256
258
|
end
|
257
259
|
|
258
260
|
def browse_bookmarks(glob)
|
261
|
+
glob_all = '**/*'
|
259
262
|
root = if glob.is_a?(Array)
|
260
|
-
glob.count.positive? ? glob : Dir.glob(
|
263
|
+
glob.count.positive? ? glob : Dir.glob(glob_all)
|
261
264
|
elsif glob && File.exist?(glob)
|
262
265
|
hooks = get_hooks(glob)
|
263
266
|
return select_hook(hooks) unless hooks.empty? || File.directory?(glob)
|
264
267
|
|
265
|
-
Dir.glob([File.expand_path(glob),
|
268
|
+
Dir.glob([File.expand_path(glob), glob_all])
|
266
269
|
else
|
267
|
-
Dir.glob(glob.nil? || glob.empty? ?
|
270
|
+
Dir.glob(glob.nil? || glob.empty? ? glob_all : glob)
|
268
271
|
end
|
269
272
|
|
270
273
|
args = ['--layout=reverse-list',
|
271
|
-
'--header="esc: cancel, return:
|
274
|
+
'--header="esc: cancel, return: browse"',
|
272
275
|
'--prompt=" Select file > "',
|
273
276
|
%(--preview='hook ls {}'),
|
274
277
|
'--height=60%',
|
275
278
|
'--min-height=10']
|
276
279
|
|
277
|
-
sel = `echo #{Shellwords.escape(root.join("\n"))} | '#{fzf}' #{args.join(' ')}`.chomp
|
278
|
-
|
280
|
+
sel = `echo #{Shellwords.escape(root.join("\n"))} | '#{fzf}' #{args.join(' ')}`.chomp.split("\n")
|
281
|
+
|
282
|
+
if sel.count == 1
|
283
|
+
marks = get_hooks(sel[0])
|
284
|
+
if marks.count.positive?
|
285
|
+
browse_linked(sel[0])
|
286
|
+
else
|
287
|
+
browse_bookmarks(glob)
|
288
|
+
end
|
289
|
+
else
|
290
|
+
open_linked(sel)
|
291
|
+
end
|
292
|
+
end
|
293
|
+
|
294
|
+
def act_on(url)
|
295
|
+
menu_items = ['Open in default app']
|
296
|
+
return open_linked(url) unless File.exist?(url)
|
297
|
+
|
298
|
+
marks = get_hooks(url)
|
299
|
+
menu_items << 'Browse file' if marks.count.positive?
|
300
|
+
|
301
|
+
args = ['--prompt="Choose action > "',
|
302
|
+
'--layout=reverse-list',
|
303
|
+
'--height=60%',
|
304
|
+
"--min-height=#{menu_items.count + 1}"]
|
305
|
+
sel = `echo #{Shellwords.escape(menu_items.join("\n"))} | '#{fzf}' #{args.join(' ')}`.chomp
|
306
|
+
return if sel.nil? || sel.empty?
|
307
|
+
|
308
|
+
case sel
|
309
|
+
when /Browse file/
|
310
|
+
browse_linked(url)
|
311
|
+
else
|
312
|
+
`open '#{url}'`
|
313
|
+
end
|
279
314
|
end
|
280
315
|
|
281
316
|
# Open the Hook GUI for browsing/performing actions on a file or url
|
@@ -296,15 +331,24 @@ class HookApp
|
|
296
331
|
|
297
332
|
# Select from a menu of available hooks and open using macOS `open`.
|
298
333
|
def open_linked(url)
|
334
|
+
marks = get_hooks(url)
|
335
|
+
if marks.empty?
|
336
|
+
warn "No hooks found for #{url}"
|
337
|
+
else
|
338
|
+
res = select_hook(marks)
|
339
|
+
res.each { |mark| `open '#{mark[:url]}'` } unless res.empty?
|
340
|
+
end
|
341
|
+
end
|
342
|
+
|
343
|
+
# Select from a menu of available hooks and open using macOS `open`.
|
344
|
+
def browse_linked(url)
|
299
345
|
marks = get_hooks(url)
|
300
346
|
if marks.empty?
|
301
347
|
warn "No hooks found for #{url}"
|
302
348
|
else
|
303
349
|
res = select_hook(marks)
|
304
350
|
unless res.empty?
|
305
|
-
res.each {|mark|
|
306
|
-
`open '#{mark[:url]}'`
|
307
|
-
}
|
351
|
+
res.each { |mark| mark[:path] ? act_on(mark[:path]) : `open '#{mark[:url]}'` }
|
308
352
|
end
|
309
353
|
end
|
310
354
|
end
|
data/lib/hook/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hookapp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brett Terpstra
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-07-
|
11
|
+
date: 2022-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aruba
|