require 'optparse' module Ios3 module CLI module Options def self.parse!(args) options = {} optparse = OptionParser.new do |opts| opts.banner = "Usage: ios3 [options]" options[:preserve_ipa] = false opts.on( '-p', '--preserve-ipa', 'Leave a copy of the .ipa file in the current directory' ) do options[:preserve_ipa] = true end options[:preserve_manifest] = false opts.on( '-m', '--preserve-manifest', 'Leave a copy of the manifest.plist file in the current directory' ) do options[:preserve_manifest] = true end opts.on( '-h', '--help', 'Display this screen' ) do puts opts exit end end begin optparse.parse!(args) rescue puts $! puts optparse exit end options end end # How the whole thing gets started def self.run(args) unless File.exist?('Rakefile') help! "Run on root directoy of RubyMotion project." end puts "HELP!!!" options = Options.parse!(ARGV) puts options ios3file = closest_ios3file(Dir.pwd) if (ios3file) Dir.chdir(File.dirname(ios3file)) ios3::DSL.load(ios3file, options) else # puts "Cannot find ios3file" say_error "Cannot find ios3file" end end def self.closest_ios3file(dir) file_name = File.join(dir, 'ios3file') if File.exists?(file_name) file_name elsif dir == '/' nil else closest_ios3file(File.expand_path(File.join(dir, '..'))) end end end end