xcselect 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/xcselect +26 -27
- data/lib/xcselect/version.rb +1 -1
- metadata +2 -2
data/bin/xcselect
CHANGED
@@ -10,14 +10,14 @@ include Xcselect
|
|
10
10
|
|
11
11
|
class Main
|
12
12
|
attr_accessor :xcodes, :current
|
13
|
-
attr_reader :exit_code
|
13
|
+
attr_reader :exit_code
|
14
14
|
def initialize
|
15
15
|
@exit_code = 0
|
16
16
|
optparse = OptionParser.new do |opts|
|
17
17
|
opts.on('-h', '--help', "Display this !!") { puts opts; exit }
|
18
18
|
opts.on('-a', '--alt' , "Alternate through all installs") { select_next() ;exit}
|
19
19
|
opts.on('-s', '--show' , "Show Current") { show_current(); exit }
|
20
|
-
opts.on('-o', '--open' , "Open
|
20
|
+
opts.on('-o', '--open' , "Open *.<xcworkspace|xcodeproj>") { open_xcode(); exit }
|
21
21
|
opts.on('-v', '--version', "Print version info") { puts "xcselect-" + VERSION; exit; }
|
22
22
|
end
|
23
23
|
begin
|
@@ -27,9 +27,9 @@ class Main
|
|
27
27
|
puts optparse
|
28
28
|
exit 2
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
optparse.parse!
|
32
|
-
|
32
|
+
|
33
33
|
begin
|
34
34
|
load_xcodes
|
35
35
|
show_menu
|
@@ -39,28 +39,27 @@ class Main
|
|
39
39
|
rescue Exception => e
|
40
40
|
puts e
|
41
41
|
puts e.backtrace
|
42
|
-
return
|
42
|
+
return
|
43
43
|
end
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
46
|
def select_next
|
47
47
|
load_xcodes
|
48
|
-
if xcodes.size > 1
|
48
|
+
if xcodes.size > 1
|
49
49
|
cur_index = xcodes.index(current)
|
50
50
|
next_index = (cur_index + 1) % xcodes.size
|
51
51
|
set_current xcodes[next_index]
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
54
|
exit
|
55
55
|
end
|
56
56
|
|
57
57
|
# fix this to take an optional arg
|
58
58
|
def open_xcode
|
59
|
-
# TODO: Add conditionall code to look for a project
|
60
|
-
# and if there isn't one then just open xcode
|
59
|
+
# TODO: Add conditionall code to look for a project
|
60
|
+
# and if there isn't one then just open xcode
|
61
61
|
xcodepath = "#{Xcode.current_xcode_path}"
|
62
|
-
|
63
|
-
open_project = projects.size > 0 ? projects.first : ""
|
62
|
+
open_project = Dir["*.xcworkspace", "*.xcodeproj"].first || ""
|
64
63
|
puts "Opening Xcode in #{xcodepath}"
|
65
64
|
`open -a "#{xcodepath}" "#{open_project}"`
|
66
65
|
end
|
@@ -69,28 +68,28 @@ class Main
|
|
69
68
|
def self.require_sudo_pass?
|
70
69
|
`sudo -n echo 1 2>&1`.chomp != "1"
|
71
70
|
end
|
72
|
-
|
71
|
+
|
73
72
|
# change the current xcode
|
74
73
|
def set_current xc
|
75
74
|
cmd = "sudo xcode-select -switch #{xc.folder}"
|
76
75
|
if Main.require_sudo_pass?
|
77
|
-
puts "Enter sudo password to select #{xc}"
|
76
|
+
puts "Enter sudo password to select #{xc}"
|
78
77
|
puts "$ #{cmd}"
|
79
78
|
end
|
80
79
|
`#{cmd}`
|
81
80
|
puts "Set Xcode to #{xc}"
|
82
81
|
end
|
83
|
-
|
82
|
+
|
84
83
|
def show_current()
|
85
84
|
cur = Xcode.new(Xcode.current_xcode)
|
86
85
|
puts cur
|
87
86
|
puts cur.sdks
|
88
87
|
end
|
89
|
-
|
88
|
+
|
90
89
|
def console_availale
|
91
90
|
STDIN.tty?
|
92
91
|
end
|
93
|
-
|
92
|
+
|
94
93
|
def select_line x
|
95
94
|
"#{x.version} (#{x.build}) #{x.folder} #{'[current]'.red if x.eql? current}"
|
96
95
|
end
|
@@ -99,7 +98,7 @@ class Main
|
|
99
98
|
puts "Please Select an Xcode ?\n\n"
|
100
99
|
i = 0;
|
101
100
|
xopts = xcodes.each do |x|
|
102
|
-
select_no = "[#{i+=1}]"
|
101
|
+
select_no = "[#{i+=1}]"
|
103
102
|
puts " #{select_no} Xcode #{select_line x}"
|
104
103
|
end
|
105
104
|
print "\nSelection: "
|
@@ -120,13 +119,13 @@ class Main
|
|
120
119
|
rescue SystemExit, Interrupt
|
121
120
|
puts ""
|
122
121
|
return
|
123
|
-
end
|
122
|
+
end
|
124
123
|
end
|
125
|
-
|
124
|
+
|
126
125
|
def find_all_with_activity_indicator
|
127
126
|
tmp_xcodes = nil;
|
128
127
|
search_thread = Thread.new { tmp_xcodes = Xcode.find_all }
|
129
|
-
display_thread = Thread.new do
|
128
|
+
display_thread = Thread.new do
|
130
129
|
sleep 0.4
|
131
130
|
if tmp_xcodes.nil?
|
132
131
|
print "Searching Spotlight "
|
@@ -135,25 +134,25 @@ class Main
|
|
135
134
|
sleep 0.4
|
136
135
|
end
|
137
136
|
print "\n"
|
138
|
-
end
|
137
|
+
end
|
139
138
|
end
|
140
139
|
|
141
140
|
search_thread.join
|
142
141
|
display_thread.join
|
143
|
-
|
142
|
+
|
144
143
|
return tmp_xcodes
|
145
144
|
end
|
146
|
-
|
145
|
+
|
147
146
|
def load_xcodes
|
148
147
|
@xcodes = find_all_with_activity_indicator
|
149
|
-
@current = xcodes.select {|x| x.folder == Xcode.current_xcode}.first
|
148
|
+
@current = xcodes.select {|x| x.folder == Xcode.current_xcode}.first
|
150
149
|
end
|
151
150
|
|
152
151
|
def to_s
|
153
152
|
"xcodes = #{xcodes}\n current = #{current}"
|
154
153
|
end
|
155
|
-
|
156
|
-
|
154
|
+
|
155
|
+
|
157
156
|
end
|
158
157
|
|
159
158
|
main = Main.new
|
data/lib/xcselect/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xcselect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-05-26 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: A more user friendly interface to the xcode-select command showing more
|
15
15
|
info, xcsim - access the simulator application folders quickly
|