<spanid="evennia-commands-cmdparser"></span><h1>evennia.commands.cmdparser<aclass="headerlink"href="#module-evennia.commands.cmdparser"title="Permalink to this headline">¶</a></h1>
<p>The default command parser. Use your own by assigning
<strong>settings.COMMAND_PARSER</strong> to a Python path to a module containing the
replacing cmdparser function. The replacement parser must accept the
<codeclass="sig-prename descclassname">evennia.commands.cmdparser.</code><codeclass="sig-name descname">create_match</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">cmdname</span></em>, <emclass="sig-param"><spanclass="n">string</span></em>, <emclass="sig-param"><spanclass="n">cmdobj</span></em>, <emclass="sig-param"><spanclass="n">raw_cmdname</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/commands/cmdparser.html#create_match"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.commands.cmdparser.create_match"title="Permalink to this definition">¶</a></dt>
<dt>This is on the form (cmdname, args, cmdobj, cmdlen, mratio, raw_cmdname),</dt><dd><p>where <strong>cmdname</strong> is the command’s name and <strong>args</strong> is the rest of the incoming
string, without said command name. <strong>cmdobj</strong> is
the Command instance, the cmdlen is the same as len(cmdname) and mratio
is a measure of how big a part of the full input string the cmdname
takes up - an exact match would be 1.0. Finally, the <strong>raw_cmdname</strong> is
the cmdname unmodified by eventual prefix-stripping.</p>
<codeclass="sig-prename descclassname">evennia.commands.cmdparser.</code><codeclass="sig-name descname">build_matches</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">raw_string</span></em>, <emclass="sig-param"><spanclass="n">cmdset</span></em>, <emclass="sig-param"><spanclass="n">include_prefixes</span><spanclass="o">=</span><spanclass="default_value">False</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/commands/cmdparser.html#build_matches"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.commands.cmdparser.build_matches"title="Permalink to this definition">¶</a></dt>
<dd><p>Build match tuples by matching raw_string against available commands.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>raw_string</strong> (<em>str</em>) – Input string that can look in any way; the only assumption is
that the sought command’s name/alias must be <em>first</em> in the string.</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 current cmdset to pick Commands from.</p></li>
<li><p><strong>include_prefixes</strong> (<em>bool</em>) – If set, include prefixes like @, ! etc (specified in settings)
in the match, otherwise strip them before matching.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>matches (list) A list of match tuples created by <strong>cmdparser.create_match</strong>.</p>
<codeclass="sig-prename descclassname">evennia.commands.cmdparser.</code><codeclass="sig-name descname">try_num_prefixes</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">raw_string</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/commands/cmdparser.html#try_num_prefixes"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.commands.cmdparser.try_num_prefixes"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-prename descclassname">evennia.commands.cmdparser.</code><codeclass="sig-name descname">cmdparser</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">raw_string</span></em>, <emclass="sig-param"><spanclass="n">cmdset</span></em>, <emclass="sig-param"><spanclass="n">caller</span></em>, <emclass="sig-param"><spanclass="n">match_index</span><spanclass="o">=</span><spanclass="default_value">None</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/commands/cmdparser.html#cmdparser"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.commands.cmdparser.cmdparser"title="Permalink to this definition">¶</a></dt>
<dd><p>This function is called by the cmdhandler once it has
gathered and merged all valid cmdsets valid for this particular parsing.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>raw_string</strong> (<em>str</em>) – The unparsed text entered by the caller.</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 merged, currently valid cmdset</p></li>
<li><p><strong>caller</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>Account</em><em> or </em><em>Object</em>) – The caller triggering this parsing.</p></li>
<li><p><strong>match_index</strong> (<em>int</em><em>, </em><em>optional</em>) – Index to pick a given match in a
list of same-named command matches. If this is given, it suggests
this is not the first time this function was called: normally
the first run resulted in a multimatch, and the index is given
to select between the results for the second run.</p></li>