forked from TheodorRene/Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathemu.rb
More file actions
121 lines (107 loc) · 2.5 KB
/
emu.rb
File metadata and controls
121 lines (107 loc) · 2.5 KB
1
2
3
4
5
6
7
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/usr/bin/env ruby
# This command will support these command
# emu list
# -- this will list all emulators and simulators. both ios and android
# emu android phone
# -- this will start an android emulator with phone size
# emu android tablet
# -- this will start an android emulator with tablet size
# emu android ipad
# -- this will start an android emulator with ipad size
# emu android iphone
# -- this will start an android emulator with iphone size
# emu ios phone
# -- this will start an ios emulator with phone size
# emu ios tablet
# -- this will start an ios emulator with tablet size
# emu ios
# -- this will default to ios phone
# emu android
# -- this will default to android phone
# emu --help
# emu help
# -- this will show the help menu
require 'optparse'
class Emu
def initialize
@ios = {
phone: 'iPhone 5s',
tablet: 'iPad Air',
}
@android = {
phone: 'Nexus 5',
tablet: 'Nexus 7',
ipad: 'Nexus 9',
iphone: 'Nexus 4',
}
end
def list
puts 'Android'
puts ' Phone'
puts ' Tablet'
puts ' iPad'
puts ' iPhone'
puts
puts 'iOS'
puts ' Phone'
puts ' Tablet'
end
def start(platform, type)
case platform
when 'android'
start_android(type)
when 'ios'
start_ios(type)
else
puts 'Invalid platform'
end
end
def start_android(type)
case type
when 'phone'
emulator(@android[:phone])
when 'tablet'
emulator(@android[:tablet])
when 'ipad'
emulator(@android[:ipad])
when 'iphone'
emulator(@android[:iphone])
else
puts 'Invalid type'
end
end
def start_ios(type)
case type
when 'phone'
emulator(@ios[:phone])
when 'tablet'
emulator(@ios[:tablet])
else
puts 'Invalid type'
end
end
def emulator(device)
system("emulator -avd '#{device}'")
end
end
options = {}
OptionParser.new do |opts|
opts.banner = 'Usage: emu [options]'
opts.on('-l', '--list', 'List all emulators and simulators') do
options[:list] = true
end
opts.on('-h', '--help', 'Show help menu') do
options[:help] = true
end
end.parse!
emu = Emu.new
if options[:list]
emu.list
elsif options[:help]
puts 'This command will support these command'
puts 'emu list'
puts '-- this will list all emulators and simulators. both ios and android'
puts 'emu android phone'
puts '-- this will start an android emulator with phone size'
puts 'emu android tablet'
puts '-- this will start an android puts 'iOS'