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
|
# File 'lib/apu.rb', line 20
def create_options_parser
@opt_parser = OptionParser.new do |opts|
opts.banner = "Usage: apu PATH [OPTIONS]"
opts.separator ''
opts.separator "Options"
opts.on('-k', '--package', 'Retrieves package name (eg. com.example.app)') do |app_path|
android_project = get_android_project_object
puts android_project.get_package_name.green
exit
end
opts.on('-u', '--uninstall', 'Uninstalls the apk from your device') do |app_path|
android_project = get_android_project_object
android_project.uninstall_application
exit
end
opts.on('-i', '--install', 'Installs the apk on your device') do |app_path|
android_project = get_android_project_object
android_project.install
exit
end
opts.on('-a', '--android-home', 'Checks if the ANDROID_HOME variable is defined') do |home|
p android_home_is_defined
exit
end
opts.on('-l', '--launcher', 'Get the launcher activity path') do |app_path|
android_project = get_android_project_object
puts android_project.get_launchable_activity.green
exit
end
opts.on('-p PATH', '--path PATH', 'Custom path to android project') do |app_path|
@app_path = app_path if @app_path != '.'
end
opts.on('-r', '--run', 'Run the build on the device') do |flavour|
android_project = get_android_project_object
android_project.install
system(android_project.get_execute_line)
exit
end
opts.on('-c', '--clear', 'Clear app data') do |flavour|
android_project = get_android_project_object
android_project.clear_app_data
end
opts.on('-h', '--help', 'Displays help') do
puts opts.help
exit
end
opts.on('-v', '--version', 'Displays version') do
puts Apu::VERSION
exit
end
end
end
|