hiiro 0.1.124 → 0.1.125
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/bin/h-app +1 -1
- data/bin/h-branch +1 -1
- data/bin/h-link +1 -7
- data/bin/h-pr +27 -163
- data/bin/h-session +3 -1
- data/bin/h-window +0 -44
- data/exe/h +1 -34
- data/hiiro.gemspec +0 -1
- data/lib/hiiro/bins.rb +19 -0
- data/lib/hiiro/tmux.rb +4 -4
- data/lib/hiiro/version.rb +1 -1
- data/lib/hiiro.rb +21 -52
- data/plugins/tasks.rb +1073 -0
- data/scripts/compare +2 -2
- metadata +3 -17
- data/lib/hiiro/queue.rb +0 -609
- data/lib/hiiro/tasks.rb +0 -1032
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7bbd061adf047bc495716f4499a6018c90563f605d3f7b51536c0df208a27ef3
|
|
4
|
+
data.tar.gz: a5d4ed3954dded40eba5af8a686972eef5c2cc0ac77e084de0f4d2fb8c94c68b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 20575a6c9652705985a3354efe441cb7bd3a4567e0946ddaf67c1cd3a7fde429e707b4d5c9e707b703f9df75396ce8c37d5716db4a64bc90a87fcf17b981c9a4
|
|
7
|
+
data.tar.gz: 3446a6a497ecda1dd2d3068ab917943d180fd6240c68bb123b99ea04255218ed30ea8bd59a6b88c7518be91064ffa0d3d3938f2ab97b78ef06c1df6f52b38892
|
data/bin/h-app
CHANGED
data/bin/h-branch
CHANGED
data/bin/h-link
CHANGED
|
@@ -7,10 +7,6 @@ require 'pry'
|
|
|
7
7
|
require 'tempfile'
|
|
8
8
|
require "hiiro"
|
|
9
9
|
|
|
10
|
-
opts = Hiiro::Options.setup {
|
|
11
|
-
option(:shorthand, short: :s)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
10
|
class LinkManager
|
|
15
11
|
LINKS_FILE = File.join(Dir.home, '.config/hiiro/links.yml')
|
|
16
12
|
LINK_TEMPLATE = {
|
|
@@ -219,12 +215,10 @@ Hiiro.run(*ARGV, plugins: [Pins], links_file: lm.links_file) do
|
|
|
219
215
|
url = add_args.shift
|
|
220
216
|
description = add_args.join(' ')
|
|
221
217
|
|
|
222
|
-
vals = opts.parse!(add_args)
|
|
223
|
-
|
|
224
218
|
new_link = LinkManager::Link.new(
|
|
225
219
|
url: url,
|
|
226
220
|
description: description,
|
|
227
|
-
shorthand:
|
|
221
|
+
shorthand: nil,
|
|
228
222
|
created_at: Time.now.iso8601
|
|
229
223
|
)
|
|
230
224
|
|
data/bin/h-pr
CHANGED
|
@@ -16,6 +16,16 @@ class PRManager
|
|
|
16
16
|
@hiiro = hiiro
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
+
def help
|
|
20
|
+
puts "Usage: h pr <subcommand> [args]"
|
|
21
|
+
puts
|
|
22
|
+
puts "Subcommands:"
|
|
23
|
+
puts " save [PR_NUMBER] Record PR for this task (auto-detects if omitted)"
|
|
24
|
+
puts " current Show current branch's PR info"
|
|
25
|
+
puts " open [PR_NUMBER] Open PR in browser"
|
|
26
|
+
puts " view [PR_NUMBER] View PR details in terminal"
|
|
27
|
+
end
|
|
28
|
+
|
|
19
29
|
def save(pr_number = nil)
|
|
20
30
|
pr_info = fetch_pr_info(pr_number)
|
|
21
31
|
unless pr_info
|
|
@@ -256,131 +266,7 @@ class PinnedPRManager
|
|
|
256
266
|
(authored_prs + assigned_prs).uniq { |pr| pr['number'] }
|
|
257
267
|
end
|
|
258
268
|
|
|
259
|
-
def
|
|
260
|
-
return true if force
|
|
261
|
-
return true unless pr['last_checked']
|
|
262
|
-
|
|
263
|
-
last_check_time = Time.parse(pr['last_checked']) rescue nil
|
|
264
|
-
return true unless last_check_time
|
|
265
|
-
|
|
266
|
-
# Refresh if last check was more than 2 minutes ago
|
|
267
|
-
(Time.now - last_check_time) > 120
|
|
268
|
-
end
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
def batch_fetch_pr_info(pr_numbers)
|
|
272
|
-
return {} if pr_numbers.empty?
|
|
273
|
-
|
|
274
|
-
# Build GraphQL query to fetch multiple PRs at once
|
|
275
|
-
pr_queries = pr_numbers.map.with_index do |num, idx|
|
|
276
|
-
<<~GRAPHQL.strip
|
|
277
|
-
pr#{idx}: pullRequest(number: #{num}) {
|
|
278
|
-
number
|
|
279
|
-
title
|
|
280
|
-
url
|
|
281
|
-
headRefName
|
|
282
|
-
state
|
|
283
|
-
isDraft
|
|
284
|
-
mergeable
|
|
285
|
-
reviewDecision
|
|
286
|
-
statusCheckRollup {
|
|
287
|
-
contexts {
|
|
288
|
-
... on CheckRun {
|
|
289
|
-
conclusion
|
|
290
|
-
status
|
|
291
|
-
}
|
|
292
|
-
... on StatusContext {
|
|
293
|
-
state
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
reviews(last: 50) {
|
|
298
|
-
nodes {
|
|
299
|
-
author {
|
|
300
|
-
login
|
|
301
|
-
}
|
|
302
|
-
state
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
GRAPHQL
|
|
307
|
-
end
|
|
308
|
-
|
|
309
|
-
query = <<~GRAPHQL
|
|
310
|
-
query {
|
|
311
|
-
repository(owner: "instacart", name: "carrot") {
|
|
312
|
-
#{pr_queries.join("\n")}
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
GRAPHQL
|
|
316
|
-
|
|
317
|
-
result = `gh api graphql -f query='#{query.gsub("'", "'\\''")}' 2>/dev/null`
|
|
318
|
-
return {} if result.empty?
|
|
319
|
-
|
|
320
|
-
data = JSON.parse(result)
|
|
321
|
-
repo_data = data.dig('data', 'repository')
|
|
322
|
-
return {} unless repo_data
|
|
323
|
-
|
|
324
|
-
# Convert GraphQL response to hash keyed by PR number
|
|
325
|
-
pr_info_by_number = {}
|
|
326
|
-
pr_numbers.each_with_index do |num, idx|
|
|
327
|
-
pr_data = repo_data["pr#{idx}"]
|
|
328
|
-
next unless pr_data
|
|
329
|
-
|
|
330
|
-
# Transform GraphQL response to match gh pr view format
|
|
331
|
-
pr_info_by_number[num] = {
|
|
332
|
-
'number' => pr_data['number'],
|
|
333
|
-
'title' => pr_data['title'],
|
|
334
|
-
'url' => pr_data['url'],
|
|
335
|
-
'headRefName' => pr_data['headRefName'],
|
|
336
|
-
'state' => pr_data['state'],
|
|
337
|
-
'isDraft' => pr_data['isDraft'],
|
|
338
|
-
'mergeable' => pr_data['mergeable'],
|
|
339
|
-
'reviewDecision' => pr_data['reviewDecision'],
|
|
340
|
-
'statusCheckRollup' => pr_data['statusCheckRollup'],
|
|
341
|
-
'reviews' => pr_data.dig('reviews', 'nodes') || []
|
|
342
|
-
}
|
|
343
|
-
end
|
|
344
|
-
|
|
345
|
-
pr_info_by_number
|
|
346
|
-
rescue JSON::ParserError, StandardError
|
|
347
|
-
{}
|
|
348
|
-
end
|
|
349
|
-
|
|
350
|
-
def refresh_all_status(prs, force: false)
|
|
351
|
-
# Determine which PRs need refreshing
|
|
352
|
-
prs_to_refresh = prs.select { |pr| needs_refresh?(pr, force: force) }
|
|
353
|
-
|
|
354
|
-
if prs_to_refresh.empty?
|
|
355
|
-
puts "All PRs recently checked (within last 2 minutes). Use -U to force update." unless force
|
|
356
|
-
return prs
|
|
357
|
-
end
|
|
358
|
-
|
|
359
|
-
# Batch fetch all PR info at once
|
|
360
|
-
pr_numbers = prs_to_refresh.map { |pr| pr['number'] }
|
|
361
|
-
fetched_info = batch_fetch_pr_info(pr_numbers)
|
|
362
|
-
|
|
363
|
-
# Update each PR with fetched info
|
|
364
|
-
prs_to_refresh.each do |pr|
|
|
365
|
-
info = fetched_info[pr['number']]
|
|
366
|
-
next unless info
|
|
367
|
-
|
|
368
|
-
pr['state'] = info['state']
|
|
369
|
-
pr['title'] = info['title']
|
|
370
|
-
pr['checks'] = summarize_checks(info['statusCheckRollup'])
|
|
371
|
-
pr['reviews'] = summarize_reviews(info['reviews'])
|
|
372
|
-
pr['review_decision'] = info['reviewDecision']
|
|
373
|
-
pr['is_draft'] = info['isDraft']
|
|
374
|
-
pr['mergeable'] = info['mergeable']
|
|
375
|
-
pr['last_checked'] = Time.now.iso8601
|
|
376
|
-
end
|
|
377
|
-
|
|
378
|
-
prs
|
|
379
|
-
end
|
|
380
|
-
|
|
381
|
-
def refresh_status(pr, force: false)
|
|
382
|
-
return pr unless needs_refresh?(pr, force: force)
|
|
383
|
-
|
|
269
|
+
def refresh_status(pr)
|
|
384
270
|
info = fetch_pr_info(pr['number'])
|
|
385
271
|
return pr unless info
|
|
386
272
|
|
|
@@ -530,7 +416,7 @@ class PinnedPRManager
|
|
|
530
416
|
end
|
|
531
417
|
end
|
|
532
418
|
|
|
533
|
-
Hiiro.run(*ARGV, plugins: [Pins]) do
|
|
419
|
+
Hiiro.run(*ARGV, plugins: [Tasks, Tmux, Pins]) do
|
|
534
420
|
manager = PRManager.new(self)
|
|
535
421
|
pinned_manager = PinnedPRManager.new
|
|
536
422
|
|
|
@@ -775,14 +661,12 @@ Hiiro.run(*ARGV, plugins: [Pins]) do
|
|
|
775
661
|
end
|
|
776
662
|
|
|
777
663
|
compact = status_args.include?('-c') || status_args.include?('--compact')
|
|
778
|
-
force = status_args.include?('-U') || status_args.include?('--force-update')
|
|
779
664
|
|
|
780
665
|
puts "Refreshing status for #{pinned.length} pinned PR(s)..."
|
|
781
666
|
puts
|
|
782
667
|
|
|
783
|
-
pinned_manager.refresh_all_status(pinned, force: force)
|
|
784
|
-
|
|
785
668
|
pinned.each_with_index do |pr, idx|
|
|
669
|
+
pinned_manager.refresh_status(pr)
|
|
786
670
|
if compact
|
|
787
671
|
puts pinned_manager.display_pinned(pr, idx)
|
|
788
672
|
else
|
|
@@ -796,7 +680,7 @@ Hiiro.run(*ARGV, plugins: [Pins]) do
|
|
|
796
680
|
puts "Status updated at #{Time.now.strftime('%H:%M:%S')}"
|
|
797
681
|
end
|
|
798
682
|
|
|
799
|
-
add_subcmd(:update) do
|
|
683
|
+
add_subcmd(:update) do
|
|
800
684
|
pinned = pinned_manager.load_pinned
|
|
801
685
|
|
|
802
686
|
if pinned.empty?
|
|
@@ -804,19 +688,15 @@ Hiiro.run(*ARGV, plugins: [Pins]) do
|
|
|
804
688
|
next
|
|
805
689
|
end
|
|
806
690
|
|
|
807
|
-
force = update_args.include?('-U') || update_args.include?('--force-update')
|
|
808
|
-
|
|
809
691
|
puts "Updating status for #{pinned.length} PR(s)..."
|
|
810
|
-
pinned_manager.
|
|
692
|
+
pinned.each { |pr| pinned_manager.refresh_status(pr) }
|
|
811
693
|
pinned_manager.save_pinned(pinned)
|
|
812
694
|
puts "Done."
|
|
813
695
|
end
|
|
814
696
|
|
|
815
|
-
add_subcmd(:green) do
|
|
697
|
+
add_subcmd(:green) do
|
|
816
698
|
pinned = pinned_manager.load_pinned
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
pinned_manager.refresh_all_status(pinned, force: force)
|
|
699
|
+
pinned.each { |pr| pinned_manager.refresh_status(pr) }
|
|
820
700
|
pinned_manager.save_pinned(pinned)
|
|
821
701
|
|
|
822
702
|
filtered = pinned.select { |pr|
|
|
@@ -834,11 +714,9 @@ Hiiro.run(*ARGV, plugins: [Pins]) do
|
|
|
834
714
|
filtered.each_with_index { |pr, i| puts pinned_manager.display_pinned(pr, i) }
|
|
835
715
|
end
|
|
836
716
|
|
|
837
|
-
add_subcmd(:red) do
|
|
717
|
+
add_subcmd(:red) do
|
|
838
718
|
pinned = pinned_manager.load_pinned
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
pinned_manager.refresh_all_status(pinned, force: force)
|
|
719
|
+
pinned.each { |pr| pinned_manager.refresh_status(pr) }
|
|
842
720
|
pinned_manager.save_pinned(pinned)
|
|
843
721
|
|
|
844
722
|
filtered = pinned.select { |pr|
|
|
@@ -856,11 +734,9 @@ Hiiro.run(*ARGV, plugins: [Pins]) do
|
|
|
856
734
|
filtered.each_with_index { |pr, i| puts pinned_manager.display_pinned(pr, i) }
|
|
857
735
|
end
|
|
858
736
|
|
|
859
|
-
add_subcmd(:old) do
|
|
737
|
+
add_subcmd(:old) do
|
|
860
738
|
pinned = pinned_manager.load_pinned
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
pinned_manager.refresh_all_status(pinned, force: force)
|
|
739
|
+
pinned.each { |pr| pinned_manager.refresh_status(pr) }
|
|
864
740
|
pinned_manager.save_pinned(pinned)
|
|
865
741
|
|
|
866
742
|
filtered = pinned.select { |pr| pr['state'] == 'MERGED' }
|
|
@@ -884,8 +760,7 @@ Hiiro.run(*ARGV, plugins: [Pins]) do
|
|
|
884
760
|
next
|
|
885
761
|
end
|
|
886
762
|
|
|
887
|
-
|
|
888
|
-
pinned_manager.refresh_all_status(pinned, force: force)
|
|
763
|
+
pinned.each { |pr| pinned_manager.refresh_status(pr) }
|
|
889
764
|
|
|
890
765
|
merged_or_closed = pinned.select { |pr| pr['state'] == 'MERGED' || pr['state'] == 'CLOSED' }
|
|
891
766
|
|
|
@@ -907,11 +782,9 @@ Hiiro.run(*ARGV, plugins: [Pins]) do
|
|
|
907
782
|
puts "Done. #{pinned_manager.load_pinned.length} PR(s) still tracked."
|
|
908
783
|
end
|
|
909
784
|
|
|
910
|
-
add_subcmd(:draft) do
|
|
785
|
+
add_subcmd(:draft) do
|
|
911
786
|
pinned = pinned_manager.load_pinned
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
pinned_manager.refresh_all_status(pinned, force: force)
|
|
787
|
+
pinned.each { |pr| pinned_manager.refresh_status(pr) }
|
|
915
788
|
pinned_manager.save_pinned(pinned)
|
|
916
789
|
|
|
917
790
|
filtered = pinned.select { |pr| pr['is_draft'] == true }
|
|
@@ -954,14 +827,7 @@ Hiiro.run(*ARGV, plugins: [Pins]) do
|
|
|
954
827
|
missing_numbers = missing.map { |pr| pr['number'] }
|
|
955
828
|
|
|
956
829
|
tmpfile = Tempfile.new(['missing-prs-', '.yml'])
|
|
957
|
-
|
|
958
|
-
missing.each do |pr|
|
|
959
|
-
lines << ''
|
|
960
|
-
lines << "# [#{pr['headRefName']}] #{pr['title']}"
|
|
961
|
-
lines << "# url: #{pr['url']}"
|
|
962
|
-
lines << "- #{pr['number']}"
|
|
963
|
-
end
|
|
964
|
-
tmpfile.write(lines.join("\n"))
|
|
830
|
+
tmpfile.write(missing_numbers.to_yaml)
|
|
965
831
|
tmpfile.close
|
|
966
832
|
|
|
967
833
|
system(ENV['EDITOR'] || 'nvim', tmpfile.path)
|
|
@@ -1078,8 +944,7 @@ Hiiro.run(*ARGV, plugins: [Pins]) do
|
|
|
1078
944
|
end
|
|
1079
945
|
|
|
1080
946
|
# Refresh all statuses first
|
|
1081
|
-
|
|
1082
|
-
pinned_manager.refresh_all_status(pinned, force: force)
|
|
947
|
+
pinned.each { |pr| pinned_manager.refresh_status(pr) }
|
|
1083
948
|
pinned_manager.save_pinned(pinned)
|
|
1084
949
|
|
|
1085
950
|
merged = pinned.select { |pr| pr['state'] == 'MERGED' }
|
|
@@ -1110,8 +975,7 @@ Hiiro.run(*ARGV, plugins: [Pins]) do
|
|
|
1110
975
|
end
|
|
1111
976
|
|
|
1112
977
|
# Refresh all statuses first
|
|
1113
|
-
|
|
1114
|
-
pinned_manager.refresh_all_status(pinned, force: force)
|
|
978
|
+
pinned.each { |pr| pinned_manager.refresh_status(pr) }
|
|
1115
979
|
|
|
1116
980
|
merged_or_closed = pinned.select { |pr| pr['state'] == 'MERGED' || pr['state'] == 'CLOSED' }
|
|
1117
981
|
|
data/bin/h-session
CHANGED
|
@@ -4,7 +4,7 @@ require 'hiiro'
|
|
|
4
4
|
require 'tempfile'
|
|
5
5
|
require 'yaml'
|
|
6
6
|
|
|
7
|
-
Hiiro.run(*ARGV,
|
|
7
|
+
Hiiro.run(*ARGV, plugins: [Pins, Tasks]) do
|
|
8
8
|
tmux = tmux_client
|
|
9
9
|
|
|
10
10
|
add_subcmd(:ls, :list) { |*args|
|
|
@@ -130,6 +130,7 @@ Hiiro.run(*ARGV, tasks: true, plugins: [Pins]) do
|
|
|
130
130
|
end
|
|
131
131
|
|
|
132
132
|
add_subcmd(:orphans) do
|
|
133
|
+
env = Environment.current
|
|
133
134
|
task_session_names = env.all_tasks.map(&:session_name)
|
|
134
135
|
orphans = env.all_sessions.reject { |s| task_session_names.include?(s.name) }
|
|
135
136
|
|
|
@@ -143,6 +144,7 @@ Hiiro.run(*ARGV, tasks: true, plugins: [Pins]) do
|
|
|
143
144
|
end
|
|
144
145
|
|
|
145
146
|
add_subcmd(:okill) do
|
|
147
|
+
env = Environment.current
|
|
146
148
|
task_session_names = env.all_tasks.map(&:session_name)
|
|
147
149
|
orphans = env.all_sessions.reject { |s| task_session_names.include?(s.name) }
|
|
148
150
|
|
data/bin/h-window
CHANGED
|
@@ -133,48 +133,4 @@ Hiiro.run(*ARGV, plugins: [Pins]) do
|
|
|
133
133
|
puts "Window not found"
|
|
134
134
|
end
|
|
135
135
|
}
|
|
136
|
-
|
|
137
|
-
add_subcmd(:vsplit) {
|
|
138
|
-
system('tmux', 'select-layout', 'even-horizontal')
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
add_subcmd(:hsplit) {
|
|
142
|
-
system('tmux', 'select-layout', 'even-vertical')
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
add_subcmd(:layout) { |q=nil|
|
|
146
|
-
layouts = {
|
|
147
|
-
mhorizontal: 'main-vertical',
|
|
148
|
-
main_horizontal: 'main-vertical',
|
|
149
|
-
ehorizontal: 'even-vertical',
|
|
150
|
-
horizontal: 'even-vertical',
|
|
151
|
-
even_horizontal: 'even-vertical',
|
|
152
|
-
|
|
153
|
-
even_vertical: 'even-horizontal',
|
|
154
|
-
evertical: 'even-horizontal',
|
|
155
|
-
vertical: 'even-horizontal',
|
|
156
|
-
main_vertical: 'main-horizontal',
|
|
157
|
-
mvertical: 'main-horizontal',
|
|
158
|
-
main_vertical_mirrored: 'main-horizontal-mirrored',
|
|
159
|
-
mmvertical: 'main-horizontal-mirrored',
|
|
160
|
-
|
|
161
|
-
tiled: 'tiled',
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
if q.nil?
|
|
165
|
-
layout = fuzzyfind(layouts)
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
if layouts.values.include?(q)
|
|
169
|
-
layout = q
|
|
170
|
-
end
|
|
171
|
-
|
|
172
|
-
if layout.nil?
|
|
173
|
-
begin
|
|
174
|
-
_, layout = Hiiro::Matcher.resolve(layouts, q) { |k,v| k }
|
|
175
|
-
end
|
|
176
|
-
end
|
|
177
|
-
|
|
178
|
-
system('tmux', 'select-layout', layout)
|
|
179
|
-
}
|
|
180
136
|
end
|
data/exe/h
CHANGED
|
@@ -3,21 +3,7 @@
|
|
|
3
3
|
require "hiiro"
|
|
4
4
|
require "fileutils"
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
if `gem list hiiro`.strip.empty?
|
|
8
|
-
system('gem', 'install', 'hiiro')
|
|
9
|
-
else
|
|
10
|
-
system('gem', 'update', 'hiiro')
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
system('h', 'setup')
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def rbenv_versions
|
|
17
|
-
versions = `rbenv versions --bare`.lines(chomp: true)
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
Hiiro.run(*ARGV, cwd: Dir.pwd, tasks: true) do
|
|
6
|
+
Hiiro.run(*ARGV, cwd: Dir.pwd, plugins: [Tasks]) do
|
|
21
7
|
add_subcmd(:version) { |*args|
|
|
22
8
|
puts Hiiro::VERSION
|
|
23
9
|
}
|
|
@@ -26,21 +12,6 @@ Hiiro.run(*ARGV, cwd: Dir.pwd, tasks: true) do
|
|
|
26
12
|
puts "pong"
|
|
27
13
|
}
|
|
28
14
|
|
|
29
|
-
add_subcmd(:install) { |*args|
|
|
30
|
-
opts = Hiiro::Options.setup {
|
|
31
|
-
flag(:all, short: :a)
|
|
32
|
-
}.parse!(ARGV)
|
|
33
|
-
|
|
34
|
-
if opts.all
|
|
35
|
-
rbenv_versions.each do |ver|
|
|
36
|
-
ENV['RBENV_VERSION'] = ver
|
|
37
|
-
update_hiiro
|
|
38
|
-
end
|
|
39
|
-
else
|
|
40
|
-
update_hiiro
|
|
41
|
-
end
|
|
42
|
-
}
|
|
43
|
-
|
|
44
15
|
add_subcmd(:setup) do |*args|
|
|
45
16
|
# Detect how the command was invoked to determine prefix
|
|
46
17
|
invoked_as = File.basename($0)
|
|
@@ -112,8 +83,4 @@ Hiiro.run(*ARGV, cwd: Dir.pwd, tasks: true) do
|
|
|
112
83
|
add_subcmd(:alert) do |*args|
|
|
113
84
|
Hiiro::Notification.show(self)
|
|
114
85
|
end
|
|
115
|
-
|
|
116
|
-
add_subcmd(:queue) do |*args|
|
|
117
|
-
Hiiro::Queue.build_hiiro(self).run
|
|
118
|
-
end
|
|
119
86
|
end
|
data/hiiro.gemspec
CHANGED
|
@@ -27,7 +27,6 @@ Gem::Specification.new do |spec|
|
|
|
27
27
|
spec.require_paths = ["lib"]
|
|
28
28
|
|
|
29
29
|
spec.add_dependency "pry", "~> 0.14"
|
|
30
|
-
spec.add_dependency "front_matter_parser"
|
|
31
30
|
|
|
32
31
|
spec.add_development_dependency "minitest", "~> 5.0"
|
|
33
32
|
spec.add_development_dependency "rake", "~> 13.0"
|
data/lib/hiiro/bins.rb
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
class Hiiro
|
|
2
|
+
class Bins
|
|
3
|
+
PATH = ENV['PATH']
|
|
4
|
+
|
|
5
|
+
def self.path = PATH
|
|
6
|
+
def self.paths = path.split(?:).map(&:strip).uniq
|
|
7
|
+
|
|
8
|
+
def self.glob(*names)
|
|
9
|
+
path_glob = [?{, paths.join(?,), ?}].join
|
|
10
|
+
name_glob = [?{, names.flatten.compact.join(?,), ?}].join
|
|
11
|
+
|
|
12
|
+
Dir[File.join(path_glob, name_glob)].select(&File.method(:executable?))
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.all
|
|
16
|
+
Dir[glob('*')].select(&File.method(:executable?))
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
data/lib/hiiro/tmux.rb
CHANGED
|
@@ -23,8 +23,8 @@ class Hiiro
|
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
-
def self.open_session(name
|
|
27
|
-
client.open_session(name
|
|
26
|
+
def self.open_session(name)
|
|
27
|
+
client.open_session(name)
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
attr_reader :hiiro
|
|
@@ -83,11 +83,11 @@ class Hiiro
|
|
|
83
83
|
run_success?('has-session', '-t', name)
|
|
84
84
|
end
|
|
85
85
|
|
|
86
|
-
def open_session(name
|
|
86
|
+
def open_session(name)
|
|
87
87
|
session_name = name.to_s
|
|
88
88
|
|
|
89
89
|
unless session_exists?(session_name)
|
|
90
|
-
|
|
90
|
+
run_system('new-session', '-d', '-A', '-s', session_name)
|
|
91
91
|
end
|
|
92
92
|
|
|
93
93
|
if in_tmux?
|
data/lib/hiiro/version.rb
CHANGED
data/lib/hiiro.rb
CHANGED
|
@@ -4,6 +4,7 @@ require "shellwords"
|
|
|
4
4
|
require "pry"
|
|
5
5
|
|
|
6
6
|
require_relative "hiiro/version"
|
|
7
|
+
require_relative "hiiro/bins"
|
|
7
8
|
require_relative "hiiro/matcher"
|
|
8
9
|
require_relative "hiiro/git"
|
|
9
10
|
require_relative "hiiro/options"
|
|
@@ -11,8 +12,6 @@ require_relative "hiiro/notification"
|
|
|
11
12
|
require_relative "hiiro/fuzzyfind"
|
|
12
13
|
require_relative "hiiro/todo"
|
|
13
14
|
require_relative "hiiro/tmux"
|
|
14
|
-
require_relative "hiiro/tasks"
|
|
15
|
-
require_relative "hiiro/queue"
|
|
16
15
|
|
|
17
16
|
class String
|
|
18
17
|
def underscore(camel_cased_word=self)
|
|
@@ -28,10 +27,7 @@ class String
|
|
|
28
27
|
end
|
|
29
28
|
|
|
30
29
|
class Hiiro
|
|
31
|
-
|
|
32
|
-
REPO_PATH = File.join(WORK_DIR, '.bare')
|
|
33
|
-
|
|
34
|
-
def self.init(*oargs, plugins: [], logging: false, tasks: false, task_scope: nil, **values, &block)
|
|
30
|
+
def self.init(*oargs, plugins: [], logging: false, **values, &block)
|
|
35
31
|
load_env
|
|
36
32
|
|
|
37
33
|
if values[:args]
|
|
@@ -43,8 +39,8 @@ class Hiiro
|
|
|
43
39
|
|
|
44
40
|
bin_name = values[:bin_name] || $0
|
|
45
41
|
|
|
46
|
-
new(bin_name, *args, logging: logging,
|
|
47
|
-
hiiro.load_plugins(plugins)
|
|
42
|
+
new(bin_name, *args, logging: logging, **values).tap do |hiiro|
|
|
43
|
+
hiiro.load_plugins(*plugins)
|
|
48
44
|
|
|
49
45
|
hiiro.add_subcommand(:pry) { |*args|
|
|
50
46
|
binding.pry
|
|
@@ -54,18 +50,6 @@ class Hiiro
|
|
|
54
50
|
system(ENV['EDITOR'] || 'nvim', hiiro.bin)
|
|
55
51
|
}
|
|
56
52
|
|
|
57
|
-
if hiiro.tasks_enabled?
|
|
58
|
-
hiiro.add_subcmd(:task) do |*args|
|
|
59
|
-
tm = TaskManager.new(hiiro, scope: :task)
|
|
60
|
-
Tasks.build_hiiro(hiiro, tm).run
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
hiiro.add_subcmd(:subtask) do |*args|
|
|
64
|
-
tm = TaskManager.new(hiiro, scope: :subtask)
|
|
65
|
-
Tasks.build_hiiro(hiiro, tm).run
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
53
|
if block
|
|
70
54
|
if block.arity == 1
|
|
71
55
|
block.call(hiiro)
|
|
@@ -76,8 +60,8 @@ class Hiiro
|
|
|
76
60
|
end
|
|
77
61
|
end
|
|
78
62
|
|
|
79
|
-
def self.run(*args, plugins: [], logging: false,
|
|
80
|
-
hiiro = init(*args, plugins:,
|
|
63
|
+
def self.run(*args, plugins: [], logging: false, **values, &block)
|
|
64
|
+
hiiro = init(*args, plugins:,logging:,**values, &block)
|
|
81
65
|
|
|
82
66
|
hiiro.run
|
|
83
67
|
end
|
|
@@ -95,17 +79,14 @@ class Hiiro
|
|
|
95
79
|
attr_reader :loaded_plugins
|
|
96
80
|
attr_reader :logging
|
|
97
81
|
attr_reader :global_values
|
|
98
|
-
attr_reader :task_scope
|
|
99
82
|
|
|
100
|
-
def initialize(bin, *all_args, logging: false,
|
|
83
|
+
def initialize(bin, *all_args, logging: false, **values)
|
|
101
84
|
@bin = bin
|
|
102
85
|
@bin_name = File.basename(bin)
|
|
103
86
|
@all_args = all_args
|
|
104
87
|
@subcmd, *@args = all_args # normally i would never do this
|
|
105
88
|
@loaded_plugins = []
|
|
106
89
|
@logging = logging
|
|
107
|
-
@tasks_enabled = tasks
|
|
108
|
-
@task_scope = task_scope
|
|
109
90
|
@global_values = values
|
|
110
91
|
@full_command = [
|
|
111
92
|
bin_name,
|
|
@@ -113,50 +94,38 @@ class Hiiro
|
|
|
113
94
|
].map(&:shellescape).join(' ')
|
|
114
95
|
end
|
|
115
96
|
|
|
116
|
-
def
|
|
117
|
-
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
def environment
|
|
121
|
-
@environment ||= Environment.current
|
|
122
|
-
end
|
|
123
|
-
alias env environment
|
|
97
|
+
def editor
|
|
98
|
+
editors = Bins.glob(%w[nvim vim vi]).find(&File.method(:executable?))
|
|
124
99
|
|
|
125
|
-
|
|
126
|
-
return nil unless tasks_enabled?
|
|
127
|
-
@task_manager ||= TaskManager.new(self, scope: task_scope || :task)
|
|
100
|
+
ENV['EDITOR'] || editors.first
|
|
128
101
|
end
|
|
129
|
-
alias tm task_manager
|
|
130
102
|
|
|
131
|
-
def
|
|
132
|
-
|
|
103
|
+
def edit_files(*files)
|
|
104
|
+
if editor.match?(/vim/i)
|
|
105
|
+
system(editor, '-O', *files)
|
|
106
|
+
else
|
|
107
|
+
system(editor, *files)
|
|
108
|
+
end
|
|
133
109
|
end
|
|
134
110
|
|
|
135
111
|
def tmux_client
|
|
136
112
|
@tmux_client ||= Tmux.client!(self)
|
|
137
113
|
end
|
|
138
114
|
|
|
139
|
-
def start_tmux_session(name
|
|
140
|
-
tmux_client.open_session(name
|
|
115
|
+
def start_tmux_session(name)
|
|
116
|
+
tmux_client.open_session(name)
|
|
141
117
|
end
|
|
142
118
|
|
|
143
|
-
def make_child(
|
|
144
|
-
|
|
145
|
-
child_args = custom_args || args
|
|
119
|
+
def make_child(subcmd, *args, **kwargs, &block)
|
|
120
|
+
bin_name = [bin, subcmd.to_s].join(?-)
|
|
146
121
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
Hiiro.init(bin_name: child_bin_name, args: child_args, **kwargs, &block)
|
|
122
|
+
Hiiro.init(bin_name:, args:, **kwargs, &block)
|
|
150
123
|
end
|
|
151
124
|
|
|
152
125
|
def todo_manager
|
|
153
126
|
@todo_manager ||= TodoManager.new
|
|
154
127
|
end
|
|
155
128
|
|
|
156
|
-
def queue
|
|
157
|
-
@queue ||= Queue.current
|
|
158
|
-
end
|
|
159
|
-
|
|
160
129
|
def run
|
|
161
130
|
result = runner.run(*args)
|
|
162
131
|
|