opts :: Option :: default_value=
Default value of this optionopts :: Option :: defaultinit
Create a new optionopts :: Option :: 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 :: Option :: defaultinit
Create a new optioncore :: Object :: defaultinit
core :: 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 :: Option :: read_param
Consume parameters for this optionopts :: OptionCount
A count option. Count the number of time this option is presentopts :: OptionText
Not really an option. Just add a line of text when displaying the usage
# Super class of all option's class
abstract class Option
# Names for the option (including long and short ones)
var names: Array[String]
# Type of the value of the option
type VALUE: nullable Object
# Human readable description of the option
var helptext: String
# Gathering errors during parsing
var errors: Array[String] = new Array[String]
# Is this option mandatory?
var mandatory: Bool = false is writable
# Has this option been read?
var read: Bool = false is writable
# Current value of this option
var value: VALUE is writable
# Default value of this option
var default_value: VALUE is writable
# Create a new option
init(help: String, default: VALUE, names: nullable Array[String]) is old_style_init do
init_opt(help, default, names)
end
# Init option `helptext`, `default_value` and `names`.
#
# Also set current `value` to `default`.
fun init_opt(help: String, default: VALUE, names: nullable Array[String])
do
if names == null then
self.names = new Array[String]
else
self.names = names.to_a
end
helptext = help
default_value = default
value = default
end
# Add new aliases for this option
fun add_aliases(names: String...) do names.add_all(names)
# An help text for this option with default settings
redef fun to_s do return pretty(2)
# A pretty print for this help
fun pretty(off: Int): String
do
var text = new FlatBuffer.from(" ")
text.append(names.join(", "))
text.append(" ")
var rest = off - text.length
if rest > 0 then text.append(" " * rest)
text.append(helptext)
#text.append(pretty_default)
return text.to_s
end
# Pretty print the default value.
fun pretty_default: String
do
var dv = default_value
if dv != null then return " ({dv.to_s})"
return ""
end
# Consume parameters for this option
protected fun read_param(opts: OptionContext, it: Iterator[String])
do
read = true
end
end
lib/opts/opts.nit:17,1--98,3