bunchcli 1.1.3 → 1.1.9.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +8 -0
- data/bin/bunch +10 -1
- data/lib/bunch/bunchCLI.rb +40 -12
- data/lib/bunch/version.rb +1 -1
- metadata +5 -6
- data/Gemfile.lock +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a0125c6936b9621c4d8252a1df185e668c8dc85c8d6ed563fd203f7f018a475
|
4
|
+
data.tar.gz: ef01962a5939067128ffd5024055561b60ee8118e09216065e3642e0a9f33c6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 282e71d31323a1496eb98f6f06e360ca8a5564f004da13ceda9939ddf2cc5b5bc3bda694250e598f51d398796ff598461e0d9250600a1e931d332f924fa7d03a
|
7
|
+
data.tar.gz: a202098f10ef8da9c3017c5c7e61e342b59dfef5cd3cb8c6fb8725cb49923b42ff430fcc23ff4a405e57ac3cb308927d7191ac1c2c8075761629c8c6a9644a3a
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
data/bin/bunch
CHANGED
@@ -18,6 +18,10 @@ bunch = Bunch.new
|
|
18
18
|
optparse = OptionParser.new do |opts|
|
19
19
|
opts.banner = "CLI for Bunch.app v#{BunchCLI::VERSION}"
|
20
20
|
|
21
|
+
opts.on('-b', '--beta', 'Use Bunch Beta for commands') do |_opt|
|
22
|
+
bunch.target_app = 'Bunch Beta'
|
23
|
+
end
|
24
|
+
|
21
25
|
opts.on('-l', '--list', 'List available Bunches') do |_opt|
|
22
26
|
bunch.list_bunches
|
23
27
|
Process.exit 0
|
@@ -65,11 +69,16 @@ optparse = OptionParser.new do |opts|
|
|
65
69
|
Process.exit 0
|
66
70
|
end
|
67
71
|
|
68
|
-
opts.on('--show-config', 'Display configuration values') do |opt|
|
72
|
+
opts.on('--show-config', 'Display all configuration values') do |opt|
|
69
73
|
bunch.show_config
|
70
74
|
Process.exit 0
|
71
75
|
end
|
72
76
|
|
77
|
+
opts.on('--show-config-key KEY', 'Display a config value [dir, toggle, method]') do |opt|
|
78
|
+
bunch.show_config(opt)
|
79
|
+
Process.exit 0
|
80
|
+
end
|
81
|
+
|
73
82
|
opts.on('-f', '--force-refresh', 'Force refresh cached preferences') do |opt|
|
74
83
|
bunch.update_cache
|
75
84
|
end
|
data/lib/bunch/bunchCLI.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
class Bunch
|
2
2
|
include Util
|
3
|
-
attr_writer :url_method, :fragment, :variables, :show_url
|
3
|
+
attr_writer :target_app, :url_method, :fragment, :variables, :show_url
|
4
4
|
|
5
5
|
def initialize
|
6
|
+
@target_app = nil
|
6
7
|
@bunch_dir = nil
|
7
8
|
@url_method = nil
|
8
9
|
@bunches = nil
|
@@ -13,15 +14,25 @@ class Bunch
|
|
13
14
|
get_cache
|
14
15
|
end
|
15
16
|
|
17
|
+
def launch_if_needed
|
18
|
+
pid = `ps ax | grep 'MacOS/Bunch'|grep -v grep`.strip
|
19
|
+
if pid == ""
|
20
|
+
`open -a Bunch`
|
21
|
+
sleep 2
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
16
25
|
def update_cache
|
17
26
|
@bunch_dir = nil
|
18
27
|
@url_method = nil
|
19
28
|
@bunches = nil
|
29
|
+
@target_app = nil
|
20
30
|
target = File.expand_path(CACHE_FILE)
|
21
31
|
settings = {
|
22
32
|
'bunchDir' => bunch_dir,
|
23
33
|
'method' => url_method,
|
24
34
|
'bunches' => bunches,
|
35
|
+
'target_app' => target_app,
|
25
36
|
'updated' => Time.now.strftime('%s').to_i
|
26
37
|
}
|
27
38
|
File.open(target,'w') do |f|
|
@@ -44,6 +55,7 @@ class Bunch
|
|
44
55
|
@bunch_dir = settings['bunchDir'] || bunch_dir
|
45
56
|
@url_method = settings['method'] || url_method
|
46
57
|
@bunches = settings['bunches'] || generate_bunch_list
|
58
|
+
@target_app = settings['target_app'] || target_app
|
47
59
|
end
|
48
60
|
|
49
61
|
def variable_query
|
@@ -61,10 +73,10 @@ class Bunch
|
|
61
73
|
# items.push({title: 0})
|
62
74
|
def generate_bunch_list
|
63
75
|
items = []
|
64
|
-
Dir.glob(File.join(bunch_dir, '
|
76
|
+
Dir.glob(File.join(bunch_dir, '**/*.bunch')).each do |f|
|
65
77
|
items.push(
|
66
78
|
path: f,
|
67
|
-
title:
|
79
|
+
title: f.sub(/^#{bunch_dir}\//,'').sub(/\.bunch$/,'')
|
68
80
|
)
|
69
81
|
end
|
70
82
|
items
|
@@ -72,13 +84,19 @@ class Bunch
|
|
72
84
|
|
73
85
|
def bunch_dir
|
74
86
|
@bunch_dir ||= begin
|
75
|
-
dir =
|
87
|
+
dir = `osascript -e 'tell app "#{@target_app}" to get preference "Folder"'`.strip
|
88
|
+
# dir = `/usr/bin/defaults read #{ENV['HOME']}/Library/Preferences/com.brettterpstra.Bunch.plist configDir`.strip
|
76
89
|
File.expand_path(dir)
|
77
90
|
end
|
78
91
|
end
|
79
92
|
|
93
|
+
def target_app
|
94
|
+
@target_app ||= "Bunch"
|
95
|
+
end
|
96
|
+
|
80
97
|
def url_method
|
81
|
-
@url_method ||=
|
98
|
+
@url_method ||= `osascript -e 'tell app "#{@target_app}" to get preference "Toggle"'`.strip == '1' ? 'toggle' : 'open'
|
99
|
+
# @url_method ||= `/usr/bin/defaults read #{ENV['HOME']}/Library/Preferences/com.brettterpstra.Bunch.plist toggleBunches`.strip == '1' ? 'toggle' : 'open'
|
82
100
|
end
|
83
101
|
|
84
102
|
def bunches
|
@@ -139,6 +157,7 @@ EOF
|
|
139
157
|
|
140
158
|
|
141
159
|
def open(str)
|
160
|
+
launch_if_needed
|
142
161
|
# get front app
|
143
162
|
front_app = %x{osascript -e 'tell application "System Events" to return name of first application process whose frontmost is true'}.strip
|
144
163
|
bid = bundle_id(front_app)
|
@@ -210,12 +229,21 @@ EOF
|
|
210
229
|
puts output
|
211
230
|
end
|
212
231
|
|
213
|
-
def show_config
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
puts
|
219
|
-
|
232
|
+
def show_config(key=nil)
|
233
|
+
case key
|
234
|
+
when /(folder|dir)/
|
235
|
+
puts bunch_dir
|
236
|
+
when /toggle/
|
237
|
+
puts url_method == 'toggle' ? 'true' : 'false'
|
238
|
+
when /method/
|
239
|
+
puts url_method
|
240
|
+
else
|
241
|
+
puts "Bunches Folder: #{bunch_dir}"
|
242
|
+
puts "Default URL Method: #{url_method}"
|
243
|
+
puts "Cached Bunches"
|
244
|
+
bunches.each {|b|
|
245
|
+
puts " - #{b[:title]}"
|
246
|
+
}
|
247
|
+
end
|
220
248
|
end
|
221
249
|
end
|
data/lib/bunch/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bunchcli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.9.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brett Terpstra
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -21,7 +21,6 @@ files:
|
|
21
21
|
- ".gitignore"
|
22
22
|
- CHANGELOG.md
|
23
23
|
- Gemfile
|
24
|
-
- Gemfile.lock
|
25
24
|
- LICENSE.txt
|
26
25
|
- README.md
|
27
26
|
- Rakefile
|
@@ -49,11 +48,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
49
48
|
version: 2.0.0
|
50
49
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
50
|
requirements:
|
52
|
-
- - "
|
51
|
+
- - ">"
|
53
52
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
53
|
+
version: 1.3.1
|
55
54
|
requirements: []
|
56
|
-
rubygems_version: 3.
|
55
|
+
rubygems_version: 3.2.3
|
57
56
|
signing_key:
|
58
57
|
specification_version: 4
|
59
58
|
summary: A CLI for use with Bunch.app (macOS)
|
data/Gemfile.lock
DELETED