Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env ruby
- require 'spaceship'
- require 'optparse'
- opt = {
- out: "out.txt",
- type: "certificate",
- user: ENV['ITUNES_CONNECT_ACCOUNT'],
- password: ENV['ITUNES_CONNECT_PASSWORD'],
- }
- OptionParser.new do |parser|
- parser.on('-i VALUE', '--id VALUE', 'CERTIFICATE_ID') {|v| opt[:id] = v}
- parser.on('-o VALUE', '--out VALUE', 'OUTPUT FILE') {|v| opt[:out] = v}
- parser.on('-u VALUE', '--user VALUE', 'ITUNES USER') {|v| opt[:user] = v}
- parser.on('-p VALUE', '--password VALUE', 'ITUNES USER PASSWORD') {|v| opt[:password] = v}
- parser.on('-t VALUE', '--type VALUE', 'FILE TYPE') {|v| opt[:type] = v}
- parser.parse!(ARGV)
- end
- Spaceship.login(opt[:user], opt[:password])
- cert = Spaceship.send(opt[:type].to_sym).all.select{|c| c.id == opt[:id]}.first.download
- case opt[:type]
- when "certificate"
- File.open(opt[:out], 'w'){|f| f.write(cert.to_s)}
- when "provisioning_profile"
- File.open(opt[:out], 'w'){|f| f.binmode; f.write(cert.to_s)}
- else
- raise "type is certificate or provisioning_profile."
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement