Property definitions

nitc $ CmdOptions :: defaultinit
# Commands options
class CmdOptions
	super HashMap[String,  String]

	# Map String visiblity name to MVisibility object
	var allowed_visibility: HashMap[String, MVisibility] is lazy do
		var res = new HashMap[String, MVisibility]
		res["public"] = public_visibility
		res["protected"] = protected_visibility
		res["private"] = private_visibility
		return res
	end

	# Get option value for `key` as String
	#
	# Return `null` if no option with that `key` or if value is empty.
	fun opt_string(key: String): nullable String do
		if not has_key(key) then return null
		var value = self[key]
		if value.is_empty then return null
		return value
	end

	# Get option value for `key` as Int
	#
	# Return `null` if no option with that `key` or if value is not an Int.
	fun opt_int(key: String): nullable Int do
		if not has_key(key) then return null
		var value = self[key]
		if not value.is_int then return null
		return value.to_i
	end

	# Get option value as bool
	#
	# Return `true` if the value with that `key` is empty or equals `"true"`.
	# Return `false` if the value with that `key` equals `"false"`.
	# Return `null` in any other case.
	fun opt_bool(key: String): nullable Bool do
		if not has_key(key) then return null
		var value = self[key]
		if value.is_empty or value == "true" then return true
		if value == "false" then return false
		return null
	end

	# Get option as a MVisibility
	#
	# Return `null` if no option with that `key` or if the value is not in
	# `allowed_visibility`.
	fun opt_visibility(key: String): nullable MVisibility do
		var value = opt_string(key)
		if value == null then return null
		if not allowed_visibility.keys.has(key) then return null
		return allowed_visibility[value]
	end

	# Get option as a MEntity
	#
	# Lookup first by `MEntity::full_name` then by `MEntity::name`.
	# Return `null` if the mentity name does not exist or return a conflict.
	private fun opt_mentity(model: Model, key: String): nullable MEntity do
		var value = opt_string(key)
		if value == null or value.is_empty then return null

		var mentity = model.mentity_by_full_name(value)
		if mentity != null then return mentity

		var mentities = model.mentities_by_name(value)
		if mentities.is_empty or mentities.length > 1 then return null
		return mentities.first
	end
end
src/doc/commands/commands_parser.nit:399,1--471,3