<pclass="last">You are reading an old version of the Evennia documentation. <ahref="https://www.evennia.com/docs/latest/index.html">The latest version is here</a></p>.
<h1>Unix-like Command style<aclass="headerlink"href="#unix-like-command-style"title="Permalink to this headline">¶</a></h1>
<p>Contribution by Vincent Le Geoff (vlgeoff), 2017</p>
<p>This module contains a command class with an alternate syntax parser implementing
Unix-style command syntax in-game. This means <codeclass="docutils literal notranslate"><spanclass="pre">--options</span></code>, positional arguments
and stuff like <codeclass="docutils literal notranslate"><spanclass="pre">-n</span><spanclass="pre">10</span></code>. It might not the best syntax for the average player
but can be really useful for builders when they need to have a single command do
many things with many options. It uses the <codeclass="docutils literal notranslate"><spanclass="pre">ArgumentParser</span></code> from Python’s standard
library under the hood.</p>
<sectionid="installation">
<h2>Installation<aclass="headerlink"href="#installation"title="Permalink to this headline">¶</a></h2>
<p>To use, inherit <codeclass="docutils literal notranslate"><spanclass="pre">UnixCommand</span></code> from this module from your own commands. You need
to override two methods:</p>
<ulclass="simple">
<li><p>The <codeclass="docutils literal notranslate"><spanclass="pre">init_parser</span></code> method, which adds options to the parser. Note that you
should normally <em>not</em> override the normal <codeclass="docutils literal notranslate"><spanclass="pre">parse</span></code> method when inheriting from
<li><p>The <codeclass="docutils literal notranslate"><spanclass="pre">func</span></code> method, called to execute the command once parsed (like any Command).</p></li>
<spanclass="n">default</span><spanclass="o">=</span><spanclass="mi">1</span><spanclass="p">,</span><spanclass="n">help</span><spanclass="o">=</span><spanclass="s2">"the age of the plant to be planted"</span><spanclass="p">)</span>
<spanclass="n">help</span><spanclass="o">=</span><spanclass="s2">"should the newly-planted plant be hidden to players?"</span><spanclass="p">)</span>
<p>To see the full power of argparse and the types of supported options, visit
<aclass="reference external"href="https://docs.python.org/2/library/argparse.html">the documentation of argparse</a>.</p>
<hrclass="docutils"/>
<p><small>This document page is generated from <codeclass="docutils literal notranslate"><spanclass="pre">evennia/contrib/base_systems/unixcommand/README.md</span></code>. Changes to this
file will be overwritten, so edit that file rather than this one.</small></p>
<pclass="last">You are reading an old version of the Evennia documentation. <ahref="https://www.evennia.com/docs/latest/index.html">The latest version is here</a></p>.
</div>
<divclass="footer"role="contentinfo">
© Copyright 2023, The Evennia developer community.
Created using <ahref="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.