8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/xcode-installer/list.rb', line 8
def action(args, options)
show_all = args.include? 'all'
show_gui = args.include? 'gui'
show_cli = args.include? 'cli'
show_gui = true if !show_all && !show_gui && !show_cli
mgr = XcodeInstaller::ReleaseManager.new
gui_versions = mgr.get_all('gui')
cli_versions = mgr.get_all('cli')
if show_all || show_gui
title = 'Xcode GUI'
table = Terminal::Table.new :title => title do |t|
t << ['Version', 'Release Date', 'Download URL']
gui_versions.each do |release|
t << :separator
row = [release['version'], release['release_date'], release['download_url']]
t << row
end
end
puts table
end
puts if show_all
os_version = `sw_vers -productVersion`
os_version = os_version.match(/\d+\.\d+/)[0]
if show_all || show_cli
title = 'Xcode Command-Line'
table = Terminal::Table.new :title => title do |t|
t << ['Version', 'Release Date', 'Download URL']
cli_versions.each do |release|
next unless release['os_version'].to_s == os_version
t << :separator
row = [release['version'], release['release_date'], release['download_url']]
t << row
end
end
puts table
end
end
|