nitc :: CmdOptions :: opt_mentity
Lookup first by MEntity::full_name
then by MEntity::name
.
Return null
if the mentity name does not exist or return a conflict.
# 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
src/doc/commands/commands_parser.nit:456,2--470,4