lib/hawk/cli.rb in hawk-1.1.2 vs lib/hawk/cli.rb in hawk-1.2.0
- old
+ new
@@ -1,11 +1,42 @@
+require 'optparse'
+
module Hawk
module CLI
+ module Options
+ def self.parse!(args)
+ options = {}
+ optparse = OptionParser.new do |opts|
+ opts.banner = "Usage: hawk [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
+
+ 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
+
def self.run(args)
+ options = Options.parse!(ARGV)
hawkfile = closest_hawkfile(Dir.pwd)
if (hawkfile)
Dir.chdir(File.dirname(hawkfile))
- Hawk::DSL.load(hawkfile)
+ Hawk::DSL.load(hawkfile, options)
else
puts "Cannot find hawkfile"
end
end