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
|
# File 'lib/iap/config.rb', line 5
def run(options, args)
configs, add_name, detail, remove = get_inputs(options, args)
if configs && configs.size > 0
raise "路径不存在!".red unless File.exist? configs
begin
json = JSON.parse(File.read(configs))
raise "读取的json不是一个数组!" unless json.is_a?(Array)
json.each do |config|
add_name = config['name']
next if add_name.nil? || add_name.empty?
add_config(add_name, config)
end
rescue StandardError => e
raise "json读取错误,请检查配置文件!".red
end
elsif add_name
strip_name = add_name.strip
raise "配置名称不能为空!".red if strip_name.empty?
add_config(strip_name)
else
configs = IAPServer::AppStoreConfig.list_configs(detail)
if configs.size > 0
return unless remove
all_num = "#{configs.size + 1}"
puts "#{all_num}) 删除所有配置".red
num = self.input("请输入前面的序号:")
return if num.empty? || num.to_i <= 0
if num == all_num
IAPServer::AppStoreConfig.clear_all_configs
elsif num.to_i > 0 && configs.size > (num.to_i - 1)
config = configs[(num.to_i - 1)]
name = config['name']
IAPServer::AppStoreConfig.clear_config(name)
else
puts "参数输入错误,退出"
end
else
puts "你还没有配置AppStore Connect的密钥和相关参数"
end
end
end
|