Advertisement
Guest User

Untitled

a guest
Apr 8th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2. require 'spaceship'
  3. require 'optparse'
  4.  
  5. opt = {
  6. out: "out.txt",
  7. type: "certificate",
  8. user: ENV['ITUNES_CONNECT_ACCOUNT'],
  9. password: ENV['ITUNES_CONNECT_PASSWORD'],
  10. }
  11. OptionParser.new do |parser|
  12. parser.on('-i VALUE', '--id VALUE', 'CERTIFICATE_ID') {|v| opt[:id] = v}
  13. parser.on('-o VALUE', '--out VALUE', 'OUTPUT FILE') {|v| opt[:out] = v}
  14. parser.on('-u VALUE', '--user VALUE', 'ITUNES USER') {|v| opt[:user] = v}
  15. parser.on('-p VALUE', '--password VALUE', 'ITUNES USER PASSWORD') {|v| opt[:password] = v}
  16. parser.on('-t VALUE', '--type VALUE', 'FILE TYPE') {|v| opt[:type] = v}
  17. parser.parse!(ARGV)
  18. end
  19.  
  20. Spaceship.login(opt[:user], opt[:password])
  21. cert = Spaceship.send(opt[:type].to_sym).all.select{|c| c.id == opt[:id]}.first.download
  22. case opt[:type]
  23. when "certificate"
  24. File.open(opt[:out], 'w'){|f| f.write(cert.to_s)}
  25. when "provisioning_profile"
  26. File.open(opt[:out], 'w'){|f| f.binmode; f.write(cert.to_s)}
  27. else
  28. raise "type is certificate or provisioning_profile."
  29. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement