nitc :: CmdEntity :: _mentity_name
Name of the mentity this command is aboutnitc :: CmdEntity :: defaultinit
nitc :: CmdEntity :: mentity_name
Name of the mentity this command is aboutnitc :: CmdEntity :: mentity_name=
Name of the mentity this command is aboutnitc :: commands_http $ CmdEntity :: http_init
Init the command from an HTTPRequestnitc :: commands_parser $ CmdEntity :: parser_init
Initialize the command from the CommandParser datanitc :: json_commands $ CmdEntity :: to_json
Return a JSON Serializable representation ofself
results
nitc :: CmdEntity :: _mentity_name
Name of the mentity this command is aboutcore :: Object :: class_factory
Implementation used byget_class
to create the specific class.
nitc :: DocCommand :: cmd_filter
Return a new filter for that command execution.nitc :: CmdEntity :: defaultinit
core :: Object :: defaultinit
nitc :: DocCommand :: defaultinit
nitc :: DocCommand :: execute
nitc :: DocCommand :: filter=
ModelFilter to apply if anynitc :: DocCommand :: http_init
Init the command from an HTTPRequestcore :: 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.
nitc :: CmdEntity :: mentity_name
Name of the mentity this command is aboutnitc :: CmdEntity :: mentity_name=
Name of the mentity this command is aboutcore :: Object :: native_class_name
The class name of the object in CString format.core :: Object :: output_class_name
Display class name on stdout (debug only).nitc :: DocCommand :: parser_init
Initialize the command from the CommandParser datanitc :: DocCommand :: to_json
Return a JSON Serializable representation ofself
results
mentity
mentity
mentity
mentity
mentity
mentity
# A command about a MEntity
class CmdEntity
super DocCommand
# MEntity this command is about
#
# Alternatively you can provide a `mentity_name`.
var mentity: nullable MEntity = null is optional, writable
# Name of the mentity this command is about
#
# Alternatively you can directly provide the `mentity`.
var mentity_name: nullable String = null is optional, writable
# Initialize the command mentity.
#
# If not already set, tries to find the `mentity` from the `mentity_name`.
#
# This function try to match `mentity_name` both as a `full_name` and
# `name`.
#
# Return states:
# * `CmdSuccess`: everything was ok;
# * `ErrorMEntityNoName`: no `mentity` and no `mentity_name` provided;
# * `ErrorMEntityNotFound`: no mentity for `mentity_name`;
# * `ErrorMEntityConflict`: `mentity_name` was a non-qualified name that
# returns more than one MEntity.
fun init_mentity: CmdMessage do
if mentity != null then
if mentity_name == null then mentity_name = mentity.as(not null).full_name
return new CmdSuccess
end
var mentity_name = self.mentity_name
if mentity_name == null or mentity_name.is_empty then return new ErrorMEntityNoName
mentity = model.mentity_by_full_name(mentity_name)
if mentity == null then
var mentities = model.mentities_by_name(mentity_name)
if mentities.is_empty then
var suggest = model.find(mentity_name, 3)
return new ErrorMEntityNotFound(mentity_name, suggest)
else if mentities.length > 1 then
return new ErrorMEntityConflict(mentity_name, mentities)
end
mentity = mentities.first
end
return new CmdSuccess
end
# See `init_mentity`.
redef fun init_command do return init_mentity
end
src/doc/commands/commands_base.nit:114,1--166,3
redef class CmdEntity
redef fun parser_init(mentity_name, options) do
self.mentity_name = mentity_name
return super
end
end
src/doc/commands/commands_parser.nit:284,1--289,3