Method: Webby::Apps::Main#parse
- Defined in:
- lib/webby/apps/main.rb
#parse(args) ⇒ Object
Parse the command line args for options and commands to invoke.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/webby/apps/main.rb', line 39 def parse( args ) opts = OptionParser.new opts. = 'Usage: webby [options] target [target args]' opts.separator '' desired_opts = %[--describe --prereqs --tasks --trace] app..each do || next unless desired_opts.include?(.first) opts.on(*) end opts.on('-o', '--options [PATTERN]', 'Show configuration options (matching optional pattern), then exit.') { |value| @command = [:show_options, value] } opts.separator '' opts.separator 'autobuild options:' opts.on('--web-server', 'Start a local web server') { [:use_web_server] = true } opts.on('--no-web-server', 'Do not start a local web server') { [:use_web_server] = false } opts.separator '' opts.separator 'common options:' opts.on_tail( '-h', '--help', 'show this message' ) do @stdout.puts opts exit end opts.on_tail( '--version', 'show version' ) do @stdout.puts "Webby #{::Webby::VERSION}" exit end opts.parse! args ARGV.replace Array(args.shift) args.delete_if do |arg| if %r/^[A-Z_]+=/ =~ arg ARGV << arg next true end false end args end |