opts :: OptionParameter :: defaultinit
opts :: OptionParameter :: parameter_mandatory
Is the parameter mandatory?opts :: OptionParameter :: parameter_mandatory=
Is the parameter mandatory?opts $ OptionParameter :: SELF
Type of this instance, automatically specialized in every classopts $ OptionParameter :: read_param
Consume parameters for this optioncore :: Object :: class_factory
Implementation used byget_class
to create the specific class.
opts :: Option :: default_value=
Default value of this optionopts :: OptionParameter :: defaultinit
core :: Object :: defaultinit
opts :: Option :: defaultinit
Create a new optioncore :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
core :: Object :: output_class_name
Display class name on stdout (debug only).opts :: OptionParameter :: parameter_mandatory
Is the parameter mandatory?opts :: OptionParameter :: parameter_mandatory=
Is the parameter mandatory?opts :: Option :: read_param
Consume parameters for this option
# 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