<spanid="evennia-commands-command"></span><h1>evennia.commands.command<aclass="headerlink"href="#module-evennia.commands.command"title="Permalink to this headline">¶</a></h1>
<p>The base Command class.</p>
<p>All commands in Evennia inherit from the ‘Command’ class in this module.</p>
<emclass="property">exception </em><codeclass="sig-prename descclassname">evennia.commands.command.</code><codeclass="sig-name descname">InterruptCommand</code><aclass="reference internal"href="../_modules/evennia/commands/command.html#InterruptCommand"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.commands.command.InterruptCommand"title="Permalink to this definition">¶</a></dt>
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.commands.command.</code><codeclass="sig-name descname">CommandMeta</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o">*</span><spanclass="n">args</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/commands/command.html#CommandMeta"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.commands.command.CommandMeta"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">__init__</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o">*</span><spanclass="n">args</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/commands/command.html#CommandMeta.__init__"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.commands.command.CommandMeta.__init__"title="Permalink to this definition">¶</a></dt>
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.commands.command.</code><codeclass="sig-name descname">Command</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/commands/command.html#Command"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.commands.command.Command"title="Permalink to this definition">¶</a></dt>
<dt>auto_help_display_key - (optional) if given, this replaces the string shown</dt><dd><p>in the auto-help listing. This is particularly useful for system-commands
<codeclass="sig-name descname">key</code><emclass="property"> = 'command'</em><aclass="headerlink"href="#evennia.commands.command.Command.key"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">aliases</code><emclass="property"> = []</em><aclass="headerlink"href="#evennia.commands.command.Command.aliases"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">locks</code><emclass="property"> = 'cmd:all();'</em><aclass="headerlink"href="#evennia.commands.command.Command.locks"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">help_category</code><emclass="property"> = 'general'</em><aclass="headerlink"href="#evennia.commands.command.Command.help_category"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">auto_help</code><emclass="property"> = True</em><aclass="headerlink"href="#evennia.commands.command.Command.auto_help"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">is_exit</code><emclass="property"> = False</em><aclass="headerlink"href="#evennia.commands.command.Command.is_exit"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">arg_regex</code><emclass="property"> = re.compile('^[ /]|\\n|$', re.IGNORECASE)</em><aclass="headerlink"href="#evennia.commands.command.Command.arg_regex"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">msg_all_sessions</code><emclass="property"> = False</em><aclass="headerlink"href="#evennia.commands.command.Command.msg_all_sessions"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">retain_instance</code><emclass="property"> = False</em><aclass="headerlink"href="#evennia.commands.command.Command.retain_instance"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">__init__</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/commands/command.html#Command.__init__"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.commands.command.Command.__init__"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">lockhandler</code><aclass="reference internal"href="../_modules/evennia/commands/command.html#Command.lockhandler"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.commands.command.Command.lockhandler"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">set_key</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">new_key</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/commands/command.html#Command.set_key"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.commands.command.Command.set_key"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">set_aliases</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">new_aliases</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/commands/command.html#Command.set_aliases"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.commands.command.Command.set_aliases"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">match</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">cmdname</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/commands/command.html#Command.match"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.commands.command.Command.match"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">access</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">srcobj</span></em>, <emclass="sig-param"><spanclass="n">access_type</span><spanclass="o">=</span><spanclass="default_value">'cmd'</span></em>, <emclass="sig-param"><spanclass="n">default</span><spanclass="o">=</span><spanclass="default_value">False</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/commands/command.html#Command.access"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.commands.command.Command.access"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">msg</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">text</span><spanclass="o">=</span><spanclass="default_value">None</span></em>, <emclass="sig-param"><spanclass="n">to_obj</span><spanclass="o">=</span><spanclass="default_value">None</span></em>, <emclass="sig-param"><spanclass="n">from_obj</span><spanclass="o">=</span><spanclass="default_value">None</span></em>, <emclass="sig-param"><spanclass="n">session</span><spanclass="o">=</span><spanclass="default_value">None</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/commands/command.html#Command.msg"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.commands.command.Command.msg"title="Permalink to this definition">¶</a></dt>
<dd><p>This is a shortcut instead of calling msg() directly on an
object - it will detect if caller is an Object or an Account and
also appends self.session automatically if self.msg_all_sessions is False.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>text</strong> (<em>str</em><em>, </em><em>optional</em>) – Text string of message to send.</p></li>
<li><p><strong>to_obj</strong> (<em>Object</em><em>, </em><em>optional</em>) – Target object of message. Defaults to self.caller.</p></li>
<li><p><strong>from_obj</strong> (<em>Object</em><em>, </em><em>optional</em>) – Source of message. Defaults to to_obj.</p></li>
<li><p><strong>session</strong> (<aclass="reference internal"href="evennia.server.session.html#evennia.server.session.Session"title="evennia.server.session.Session"><em>Session</em></a><em>, </em><em>optional</em>) – Supply data only to a unique
session (ignores the value of <strong>self.msg_all_sessions</strong>).</p></li>
</ul>
</dd>
<dtclass="field-even">Keyword Arguments</dt>
<ddclass="field-even"><ulclass="simple">
<li><p><strong>options</strong> (<em>dict</em>) – Options to the protocol.</p></li>
<li><p><strong>any</strong> (<em>any</em>) – All other keywords are interpreted as th
<codeclass="sig-name descname">execute_cmd</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">raw_string</span></em>, <emclass="sig-param"><spanclass="n">session</span><spanclass="o">=</span><spanclass="default_value">None</span></em>, <emclass="sig-param"><spanclass="n">obj</span><spanclass="o">=</span><spanclass="default_value">None</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/commands/command.html#Command.execute_cmd"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.commands.command.Command.execute_cmd"title="Permalink to this definition">¶</a></dt>
<dd><p>A shortcut of execute_cmd on the caller. It appends the
session automatically.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>raw_string</strong> (<em>str</em>) – Execute this string as a command input.</p></li>
<li><p><strong>session</strong> (<aclass="reference internal"href="evennia.server.session.html#evennia.server.session.Session"title="evennia.server.session.Session"><em>Session</em></a><em>, </em><em>optional</em>) – If not given, the current command’s Session will be used.</p></li>
<li><p><strong>obj</strong> (<em>Object</em><em> or </em><em>Account</em><em>, </em><em>optional</em>) – Object or Account on which to call the execute_cmd.
If not given, self.caller will be used.</p></li>
</ul>
</dd>
<dtclass="field-even">Keyword Arguments</dt>
<ddclass="field-even"><ulclass="simple">
<li><p><strong>keyword arguments will be added to the found command</strong> (<em>Other</em>) –</p></li>
<li><p><strong>instace as variables before it executes. This is</strong> (<aclass="reference internal"href="evennia.scripts.models.html#evennia.scripts.models.ScriptDB.object"title="evennia.scripts.models.ScriptDB.object"><em>object</em></a>) –</p></li>
<li><p><strong>by default Evennia but may be used to set flags and</strong> (<em>unused</em>) –</p></li>
<li><p><strong>operating paramaters for commands at run-time.</strong> (<em>change</em>) –</p></li>
<codeclass="sig-name descname">at_pre_cmd</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/commands/command.html#Command.at_pre_cmd"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.commands.command.Command.at_pre_cmd"title="Permalink to this definition">¶</a></dt>
<dd><p>This hook is called before self.parse() on all commands. If
this hook returns anything but False/None, the command
<codeclass="sig-name descname">at_post_cmd</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/commands/command.html#Command.at_post_cmd"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.commands.command.Command.at_post_cmd"title="Permalink to this definition">¶</a></dt>
<dd><p>This hook is called after the command has finished executing
<codeclass="sig-name descname">parse</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/commands/command.html#Command.parse"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.commands.command.Command.parse"title="Permalink to this definition">¶</a></dt>
<dd><p>Once the cmdhandler has identified this as the command we
want, this function is run. If many of your commands have a
similar syntax (for example ‘cmd arg1 = arg2’) you should
simply define this once and just let other commands of the
same form inherit from this. See the docstring of this module
for which object properties are available to use (notably
<codeclass="sig-name descname">get_command_info</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/commands/command.html#Command.get_command_info"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.commands.command.Command.get_command_info"title="Permalink to this definition">¶</a></dt>
<dd><p>This is the default output of func() if no func() overload is done.
Provided here as a separate method so that it can be called for debugging
<codeclass="sig-name descname">func</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/commands/command.html#Command.func"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.commands.command.Command.func"title="Permalink to this definition">¶</a></dt>
<dd><p>This is the actual executing part of the command. It is
called directly after self.parse(). See the docstring of this
module for which object properties are available (beyond those
<codeclass="sig-name descname">get_extra_info</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">caller</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/commands/command.html#Command.get_extra_info"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.commands.command.Command.get_extra_info"title="Permalink to this definition">¶</a></dt>
<dd><p>Display some extra information that may help distinguish this
command from others, for instance, in a disambiguity prompt.</p>
<p>If this command is a potential match in an ambiguous
situation, one distinguishing feature may be its attachment to
a nearby object, so we include this if available.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>caller</strong> (<aclass="reference internal"href="evennia.typeclasses.models.html#evennia.typeclasses.models.TypedObject"title="evennia.typeclasses.models.TypedObject"><em>TypedObject</em></a>) – The caller who typed an ambiguous</p></li>
<li><p><strong>handed to the search function.</strong> (<em>term</em>) –</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>A string with identifying information to disambiguate the
object, conventionally with a preceding space.</p>
<codeclass="sig-name descname">get_help</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">caller</span></em>, <emclass="sig-param"><spanclass="n">cmdset</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/commands/command.html#Command.get_help"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.commands.command.Command.get_help"title="Permalink to this definition">¶</a></dt>
<dd><p>Return the help message for this command and this caller.</p>
<p>By default, return self.__doc__ (the docstring just under
the class definition). You can override this behavior,
though, and even customize it depending on the caller, or other
commands the caller can use.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>caller</strong> (<em>Object</em><em> or </em><em>Account</em>) – the caller asking for help on the command.</p></li>
<li><p><strong>cmdset</strong> (<aclass="reference internal"href="evennia.commands.cmdset.html#evennia.commands.cmdset.CmdSet"title="evennia.commands.cmdset.CmdSet"><em>CmdSet</em></a>) – the command set (if you need additional commands).</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><em>docstring (str)</em>– the help text to provide the caller for this command.</p>
<codeclass="sig-name descname">web_get_detail_url</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/commands/command.html#Command.web_get_detail_url"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.commands.command.Command.web_get_detail_url"title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the URI path for a View that allows users to view details for
this object.</p>
<p>ex. Oscar (Character) = ‘/characters/oscar/1/’</p>
<p>For this to work, the developer must have defined a named view somewhere
in urls.py that follows the format ‘modelname-action’, so in this case
a named view of ‘character-detail’ would be referenced by this method.</p>
<codeclass="sig-name descname">web_get_admin_url</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/commands/command.html#Command.web_get_admin_url"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.commands.command.Command.web_get_admin_url"title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the URI path for the Django Admin page for this object.</p>
<codeclass="sig-name descname">client_width</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/commands/command.html#Command.client_width"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.commands.command.Command.client_width"title="Permalink to this definition">¶</a></dt>
<dd><p>Get the client screenwidth for the session using this command.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Returns</dt>
<ddclass="field-odd"><p><em>client width (int)</em>– The width (in characters) of the client window.</p>
<codeclass="sig-name descname">styled_table</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o">*</span><spanclass="n">args</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/commands/command.html#Command.styled_table"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.commands.command.Command.styled_table"title="Permalink to this definition">¶</a></dt>
<dt>An initialized evtable entity, either complete (if using <strong>table</strong> kwarg)</dt><dd><p>or incomplete and ready for use with <strong>.add_row</strong> or <strong>.add_collumn</strong>.</p>
<codeclass="sig-name descname">styled_header</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o">*</span><spanclass="n">args</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/commands/command.html#Command.styled_header"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.commands.command.Command.styled_header"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">styled_separator</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o">*</span><spanclass="n">args</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/commands/command.html#Command.styled_separator"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.commands.command.Command.styled_separator"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">styled_footer</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o">*</span><spanclass="n">args</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/commands/command.html#Command.styled_footer"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.commands.command.Command.styled_footer"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">lock_storage</code><emclass="property"> = 'cmd:all();'</em><aclass="headerlink"href="#evennia.commands.command.Command.lock_storage"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">save_for_next</code><emclass="property"> = False</em><aclass="headerlink"href="#evennia.commands.command.Command.save_for_next"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">search_index_entry</code><emclass="property"> = {'aliases': '', 'category': 'general', 'key': 'command', 'no_prefix': ' ', 'tags': '', 'text': '\n ## Base command\n\n (you may see this if a child command had no help text defined)\n\n Usage:\n command [args]\n\n This is the base command class. Inherit from this\n to create new commands.\n\n The cmdhandler makes the following variables available to the\n command methods (so you can always assume them to be there):\n self.caller - the game object calling the command\n self.cmdstring - the command name used to trigger this command (allows\n you to know which alias was used, for example)\n cmd.args - everything supplied to the command following the cmdstring\n (this is usually what is parsed in self.parse())\n cmd.cmdset - the cmdset from which this command was matched (useful only\n seldomly, notably for help-type commands, to create dynamic\n help entries and lists)\n cmd.obj - the object on which this command is defined. If a default command,\n this is usually the same as caller.\n cmd.rawstring - the full raw string input, including any args and no parsing.\n\n The following class properties can/should be defined on your child class:\n\n key - identifier for command (e.g. "look")\n aliases - (optional) list of aliases (e.g. ["l", "loo"])\n locks - lock string (default is "cmd:all()")\n help_category - how to organize this help entry in help system\n (default is "General")\n auto_help - defaults to True. Allows for turning off auto-help generation\n arg_regex - (optional) raw string regex defining how the argument part of\n the command should look in order to match for this command\n (e.g. must it be a space between cmdname and arg?)\n auto_help_display_key - (optional) if given, this replaces the string shown\n in the auto-help listing. This is particularly useful for system-commands\n whose actual key is not really meaningful.\n\n (Note that if auto_help is on, this initial string is also used by the\n system to create the help entry for the command, so it\'s a good idea to\n format it similar to this one). This behavior can be changed by\n overriding the method \'get_help\' of a command: by default, this\n method returns cmd.__doc__ (that is, this very docstring, or\n the docstring of your command). You can, however, extend or\n replace this without disabling auto_help.\n '}</em><aclass="headerlink"href="#evennia.commands.command.Command.search_index_entry"title="Permalink to this definition">¶</a></dt>