diff --git a/versions/doc-improvements/docs/api/commander/index.html b/versions/doc-improvements/docs/api/commander/index.html index 2e8c68d..582a5f8 100644 --- a/versions/doc-improvements/docs/api/commander/index.html +++ b/versions/doc-improvements/docs/api/commander/index.html @@ -2,11 +2,10 @@

Module commander

library for custom commands

Introduction -

Commander is a library for writing custom commands in Lua. -In order to make it easier to write commands for Hilbish, -not require separate scripts and to be able to use in a config, -the Commander library exists. This is like a very simple wrapper -that works with Hilbish for writing commands. Example:

1local commander = require 'commander'
+

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.

1local commander = require 'commander'
 2
 3commander.register('hello', function(args, sinks)
 4	sinks.out:writeln 'Hello world!'
@@ -14,12 +13,22 @@ that works with Hilbish for writing commands. Example:

<

In this example, a command with the name of hello is created that will print Hello world! to output. One question you may have is: What is the sinks parameter?

The sinks parameter is a table with 3 keys: in, out, -and err. The values of these is a Sink.

  • in is the standard input. You can read from this sink -to get user input.
  • out is standard output. This is usually where text meant for -output should go.
  • err is standard error. This sink is for writing errors, as the -name would suggest.

Functions -

deregister(name)Deregisters any command registered with name
register(name, cb)Register a command with name that runs cb when ran

commander.deregister(name) -

Deregisters any command registered with name

Parameters -

This function has no parameters.


commander.register(name, cb) -

Register a command with name that runs cb when ran

Parameters -

This function has no parameters.

\ No newline at end of file +and err. All of them are a Sink.

  • in is the standard input. +You may use the read functions on this sink to get input from the user.
  • out is standard output. +This is usually where command output should go.
  • err is standard error. +This sink is for writing errors, as the name would suggest.

Functions +

deregister(name)Removes the named command. Note that this will only remove Commander-registered commands.
register(name, cb)Adds a new command with the given name. When Hilbish has to run a command with a name,

commander.deregister(name) +

Removes the named command. Note that this will only remove Commander-registered commands.

Parameters +

string name
Name of the command to remove.


commander.register(name, cb) +

Adds a new command with the given name. When Hilbish has to run a command with a name, +it will run the function providing the arguments and sinks.

Parameters +

string name
Name of the command

function cb
Callback to handle command invocation

Example +
1-- When you run the command `hello` in the shell, it will print `Hello world`.
+2-- If you run it with, for example, `hello Hilbish`, it will print 'Hello Hilbish'
+3commander.register('hello', function(args, sinks)
+4	local name = 'world'
+5	if #args > 0 then name = args[1] end
+6
+7	sinks.out:writeln('Hello ' .. name)
+8end)
+
\ No newline at end of file diff --git a/versions/doc-improvements/docs/api/index.xml b/versions/doc-improvements/docs/api/index.xml index c51b596..8a03c20 100644 --- a/versions/doc-improvements/docs/api/index.xml +++ b/versions/doc-improvements/docs/api/index.xml @@ -1,5 +1,5 @@ API on Hilbishhttps://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/Recent content in API on HilbishHugo -- gohugo.ioen-usModule baithttps://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/bait/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/bait/Introduction Bait is the event emitter for Hilbish. Much like Node.js and its events system, many actions in Hilbish emit events. Unlike Node.js, Hilbish events are global. So make sure to pick a unique name! -Usage of the Bait module consists of userstanding event-driven architecture, but it&rsquo;s pretty simple: If you want to act on a certain event, you can catch it. You can act on events via callback functions.Module commanderhttps://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/commander/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/commander/Introduction Commander is a library for writing custom commands in Lua. In order to make it easier to write commands for Hilbish, not require separate scripts and to be able to use in a config, the Commander library exists. This is like a very simple wrapper that works with Hilbish for writing commands. Example: +Usage of the Bait module consists of userstanding event-driven architecture, but it&rsquo;s pretty simple: If you want to act on a certain event, you can catch it. You can act on events via callback functions.Module commanderhttps://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/commander/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/commander/Introduction 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. 1local commander = require &#39;commander&#39; 2 3commander.register(&#39;hello&#39;, function(args, sinks) 4 sinks.out:writeln &#39;Hello world!&#39; 5end) In this example, a command with the name of hello is created that will print Hello world!Module fshttps://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/fs/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/fs/Introduction The fs module provides easy and simple access to filesystem functions and other things, and acts an addition to the Lua standard library&rsquo;s I/O and filesystem functions. Functions abs(path) -&gt; string Gives an absolute version of path. basename(path) -&gt; string Gives the basename of path. For the rules, cd(dir) Changes directory to dir dir(path) -&gt; string Returns the directory part of path. For the rules, see Go&rsquo;s glob(pattern) -&gt; matches (table) Glob all files and directories that match the pattern.Module terminalhttps://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/terminal/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/terminal/Introduction The terminal library is a simple and lower level library for certain terminal interactions. Functions restoreState() Restores the last saved state of the terminal saveState() Saves the current state of the terminal setRaw() Puts the terminal in raw mode size() Gets the dimensions of the terminal. Returns a table with width and height terminal.restoreState() Restores the last saved state of the terminal diff --git a/versions/doc-improvements/index.xml b/versions/doc-improvements/index.xml index 805ec23..7c878b6 100644 --- a/versions/doc-improvements/index.xml +++ b/versions/doc-improvements/index.xml @@ -31,7 +31,7 @@ hilbish.vimAction -&gt; actionName, args &gt; Sent when the user does a hilbish.cancel &gt; Sent when the user cancels their input with Ctrl-C.Installhttps://rosettea.github.io/Hilbish/versions/doc-improvements/install/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/versions/doc-improvements/install/Official Binaries The best way to get Hilbish is to get a build directly from GitHub. At any time, there are 2 versions of Hilbish recommended for download: the latest stable release, and development builds from the master branch. You can download both at any time, but note that the development builds may have breaking changes. For the latest stable release, check here: https://github.com/Rosettea/Hilbish/releases/latest For a development build: https://nightly.link/Rosettea/Hilbish/workflows/build/master Compiling To read the steps for compiling Hilbish, head over to the GitHub repository.Module baithttps://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/bait/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/bait/Introduction Bait is the event emitter for Hilbish. Much like Node.js and its events system, many actions in Hilbish emit events. Unlike Node.js, Hilbish events are global. So make sure to pick a unique name! -Usage of the Bait module consists of userstanding event-driven architecture, but it&rsquo;s pretty simple: If you want to act on a certain event, you can catch it. You can act on events via callback functions.Module commanderhttps://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/commander/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/commander/Introduction Commander is a library for writing custom commands in Lua. In order to make it easier to write commands for Hilbish, not require separate scripts and to be able to use in a config, the Commander library exists. This is like a very simple wrapper that works with Hilbish for writing commands. Example: +Usage of the Bait module consists of userstanding event-driven architecture, but it&rsquo;s pretty simple: If you want to act on a certain event, you can catch it. You can act on events via callback functions.Module commanderhttps://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/commander/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/commander/Introduction 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. 1local commander = require &#39;commander&#39; 2 3commander.register(&#39;hello&#39;, function(args, sinks) 4 sinks.out:writeln &#39;Hello world!&#39; 5end) In this example, a command with the name of hello is created that will print Hello world!Module fshttps://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/fs/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/fs/Introduction The fs module provides easy and simple access to filesystem functions and other things, and acts an addition to the Lua standard library&rsquo;s I/O and filesystem functions. Functions abs(path) -&gt; string Gives an absolute version of path. basename(path) -&gt; string Gives the basename of path. For the rules, cd(dir) Changes directory to dir dir(path) -&gt; string Returns the directory part of path. For the rules, see Go&rsquo;s glob(pattern) -&gt; matches (table) Glob all files and directories that match the pattern.Module hilbish.aliaseshttps://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/hilbish/hilbish.aliases/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/hilbish/hilbish.aliases/Introduction The alias interface deals with all command aliases in Hilbish. Functions add(alias, cmd) This is an alias (ha) for the hilbish.alias function. delete(name) Removes an alias. list() -&gt; table&lt;string, string&gt; Get a table of all aliases, with string keys as the alias and the value as the command. resolve(alias) -&gt; command (string) Tries to resolve an alias to its command. hilbish.aliases.add(alias, cmd) This is an alias (ha) for the hilbish.Module hilbish.completionshttps://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/hilbish/hilbish.completions/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/hilbish/hilbish.completions/Introduction The completions interface deals with tab completions.