Method: MSpecOptions#parse
- Defined in:
- lib/mspec/utils/options.rb
#parse(argv = ARGV) ⇒ Object
Parses an array of command line entries, calling blocks for registered options.
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/mspec/utils/options.rb', line 122 def parse(argv=ARGV) argv = Array(argv).dup while entry = argv.shift # collect everything that is not an option if entry[0] != ?- or entry.size < 2 @on_extra[entry] next end # this is a long option if entry[1] == ?- opt, arg = entry.split "=" process argv, entry, opt, arg next end # disambiguate short option group from short option with argument opt, arg, rest = split entry, 2 # process first option option = process argv, entry, opt, arg next unless option and not option.arg? # process the rest of the options while rest.size > 0 opt, arg, rest = split rest, 1 opt = "-" + opt option = process argv, opt, opt, arg break if option.arg? end end @extra rescue ParseError => e puts self puts e exit 1 end |