Property definitions

opts $ OptionParameter :: defaultinit
# Option with one parameter (mandatory by default)
abstract class OptionParameter
	super Option

	# Convert `str` to a value of type `VALUE`.
	protected fun convert(str: String): VALUE is abstract

	# Is the parameter mandatory?
	var parameter_mandatory = true is writable

	redef fun read_param(opts, it)
	do
		super

		var ok = it.is_ok
		if ok and not parameter_mandatory and not it.item.is_empty and it.item.chars.first == '-' then
			# The next item may looks like a known command
			# Only check if `not parameter_mandatory`
			for opt in opts.options do
				if opt.names.has(it.item) then
					# The next item is a known command
					ok = false
					break
				end
			end
		end

		if ok then
			value = convert(it.item)
			it.next
		else
			errors.add("Parameter expected for option {names.first}.")
		end
	end
end
lib/opts/opts.nit:142,1--176,3