Parse the command line

Property definitions

opts $ OptionContext :: parse_intern
	# Parse the command line
	protected fun parse_intern(it: Iterator[String])
	do
		var parseargs = true
		build
		var rest = rest

		while parseargs and it.is_ok do
			var str = it.item
			if str == "--" then
				it.next
				rest.add_all(it.to_a)
				parseargs = false
			else
				# We're looking for packed short options
				if str.chars.last_index_of('-') == 0 and str.length > 2 then
					var next_called = false
					for i in [1..str.length[ do
						var short_opt = "-" + str.chars[i].to_s
						if optmap.has_key(short_opt) then
							var option = optmap[short_opt]
							if option isa OptionParameter then
								it.next
								next_called = true
							end
							option.read_param(self, it)
						end
					end
					if not next_called then it.next
				else
					if optmap.has_key(str) then
						var opt = optmap[str]
						it.next
						opt.read_param(self, it)
					else
						rest.add(it.item)
						it.next
						if options_before_rest then
							rest.add_all(it.to_a)
							parseargs = false
						end
					end
				end
			end
		end

		for opt in options do
			if opt.mandatory and not opt.read then
				context_errors.add("Mandatory option {opt.names.join(", ")} not found.")
			end
		end
	end
lib/opts/opts.nit:332,2--383,4