<ahref=#introductionclass=heading-link><iclass="fas fa-paperclip"></i></a></h3><p>Commander is the library which handles Hilbish commands. This makes
the user able to add Lua-written commands to their shell without making
a separate script in a bin folder. Instead, you may simply use the Commander
library in your Hilbish config.</p><divclass=highlight><pretabindex=0class=chroma><codeclass=language-luadata-lang=lua><spanclass=line><spanclass=ln>1</span><spanclass=cl><spanclass=kd>local</span><spanclass=n>commander</span><spanclass=o>=</span><spanclass=n>require</span><spanclass=s1>'commander'</span>
</span></span></code></pre></div><p>In this example, a command with the name of <code>hello</code> is created
that will print <code>Hello world!</code> to output. One question you may
have is: What is the <code>sinks</code> parameter?</p><p>The <code>sinks</code> parameter is a table with 3 keys: <code>input</code>, <code>out</code>, and <code>err</code>.
There is an <code>in</code> alias to <code>input</code>, but it requires using the string accessor syntax (<code>sinks['in']</code>)
as <code>in</code> is also a Lua keyword, so <code>input</code> is preferred for use.
All of them are a <ahref=/Hilbish/docs/api/hilbish/#sinkstyle=text-decoration:none>Sink</a>.
In the future, <code>sinks.in</code> will be removed.</p><ul><li><code>in</code> is the standard input.
You may use the read functions on this sink to get input from the user.</li><li><code>out</code> is standard output.
This is usually where command output should go.</li><li><code>err</code> is standard error.
This sink is for writing errors, as the name would suggest.</li></ul><h3id=functionsclass=heading>Functions
<ahref=#functionsclass=heading-link><iclass="fas fa-paperclip"></i></a></h3><table><thead><tr><th></th><th></th></tr></thead><tbody><tr><td><ahref=#deregister>deregister(name)</a></td><td>Removes the named command. Note that this will only remove Commander-registered commands.</td></tr><tr><td><ahref=#register>register(name, cb)</a></td><td>Adds a new command with the given <code>name</code>. When Hilbish has to run a command with a name,</td></tr><tr><td><ahref=#registry>registry() -> table</a></td><td>Returns all registered commanders. Returns a list of tables with the following keys:</td></tr></tbody></table><hr><divid=deregister><h4class=heading>commander.deregister(name)
<ahref=#deregisterclass=heading-link><iclass="fas fa-paperclip"></i></a></h4><p>Removes the named command. Note that this will only remove Commander-registered commands.</p><h5id=parametersclass=heading>Parameters
<ahref=#parametersclass=heading-link><iclass="fas fa-paperclip"></i></a></h5><p><code>string</code><strong><code>name</code></strong><br>Name of the command to remove.</p></div><hr><divid=register><h4class=heading>commander.register(name, cb)
<ahref=#registerclass=heading-link><iclass="fas fa-paperclip"></i></a></h4><p>Adds a new command with the given <code>name</code>. When Hilbish has to run a command with a name,<br>it will run the function providing the arguments and sinks.</p><h5id=parameters-1class=heading>Parameters
<ahref=#parameters-1class=heading-link><iclass="fas fa-paperclip"></i></a></h5><p><code>string</code><strong><code>name</code></strong><br>Name of the command</p><p><code>function</code><strong><code>cb</code></strong><br>Callback to handle command invocation</p><h5id=exampleclass=heading>Example
<ahref=#exampleclass=heading-link><iclass="fas fa-paperclip"></i></a></h5><divclass=highlight><pretabindex=0class=chroma><codeclass=language-luadata-lang=lua><spanclass=line><spanclass=ln>1</span><spanclass=cl><spanclass=c1>-- When you run the command `hello` in the shell, it will print `Hello world`.</span>
</span></span><spanclass=line><spanclass=ln>2</span><spanclass=cl><spanclass=c1>-- If you run it with, for example, `hello Hilbish`, it will print 'Hello Hilbish'</span>
<ahref=#registryclass=heading-link><iclass="fas fa-paperclip"></i></a></h4><p>Returns all registered commanders. Returns a list of tables with the following keys:</p><ul><li><code>exec</code>: The function used to run the commander. Commanders require args and sinks to be passed.</li></ul><h5id=parameters-2class=heading>Parameters