forked from bitrise-steplib/steps-xcode-archive-mac
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_export_options.rb
59 lines (47 loc) · 1.65 KB
/
generate_export_options.rb
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
require 'optparse'
require 'plist'
require 'json'
# -----------------------
# --- functions
# -----------------------
def fail_with_message(message)
puts "\e[31m#{message}\e[0m"
exit(1)
end
# -----------------------
# --- main
# -----------------------
puts
# Input validation
options = {
export_options_path: nil,
archive_path: nil,
export_method: nil
}
parser = OptionParser.new do|opts|
opts.banner = 'Usage: step.rb [options]'
opts.on('-o', '--export_options_path path', 'Export options path') { |o| options[:export_options_path] = o unless o.to_s == '' }
opts.on('-a', '--archive_path path', 'Archive path') { |a| options[:archive_path] = a unless a.to_s == '' }
opts.on('-e', '--export_method method', 'Export method') { |a| options[:export_method] = a unless a.to_s == '' }
opts.on('-h', '--help', 'Displays Help') do
puts opts
exit
end
end
parser.parse!
fail_with_message('export_options_path not specified') unless options[:export_options_path]
puts "(i) export_options_path: #{options[:export_options_path]}"
fail_with_message('archive_path not specified') unless options[:archive_path]
puts "(i) archive_path: #{options[:archive_path]}"
method = options[:export_method] unless options[:export_method] == 'none'
puts
puts '==> Create export options'
export_options = {}
# export_options[:teamID] = team_id unless team_id.nil?
export_options[:method] = method unless method.nil?
puts
puts " (i) export_options: #{export_options}"
plist_content = Plist::Emit.dump(export_options)
puts " (i) plist_content: #{plist_content}"
puts " (i) saving into file: #{options[:export_options_path]}"
File.write(options[:export_options_path], plist_content)