Sha256: 86fdde1636e0ff6032cef429dc3f6e724e1a8dc8f5b53eb4786912177593d990

Contents?: true

Size: 1.67 KB

Versions: 3

Compression:

Stored size: 1.67 KB

Contents

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ios3-0.0.5 lib/ios3/cli.rb
ios3-0.0.4 lib/ios3/cli.rb
ios3-0.0.3 lib/ios3/cli.rb