-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpull_apks.rb
More file actions
40 lines (30 loc) · 968 Bytes
/
Copy pathpull_apks.rb
File metadata and controls
40 lines (30 loc) · 968 Bytes
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
# frozen_string_literal: true
require_relative 'validate_package'
class PullApks
def self.name
'pull_apks'
end
def self.perform(*args)
cli_package_name = nil
options = OptionParser.new do |option|
# find package name from optional
option.on("--package PACKAGE", "Package name") { |value| cli_package_name = value }
end
orderedArguments = options.parse(args)
package = get_package(cli_package_name)
return unless validate_package(package)
stdout_str, = Open3.capture2("adb shell pm path #{package}")
locations = stdout_str.split("\n").map do |row|
# remove the "package:" part of each line
row.sub('package:', '')
end
destination = orderedArguments.shift
puts "Pulling apk(s) for #{package}"
locations.each do |location|
Open3.capture2("adb pull #{location} #{destination}")
end
end
def self.similar_sounding_commands
%w[pull apk apks download get]
end
end