From 1f5462cef618ddbd814a2cb5f872e862bdae77a8 Mon Sep 17 00:00:00 2001
From: sammy-ette Catches an event. This function can be used to act on events. Catches an event. This function can be used to act on events. Catches an event, but only once. This will remove the hook immediately after it runs for the first time. Catches an event, but only once. This will remove the hook immediately after it runs for the first time. Returns a table of functions that are hooked on an event with the corresponding Returns a table of functions that are hooked on an event with the corresponding Removes the Throws a hook with Throws a hook with Removes the named command. Note that this will only remove Commander-registered commands. Removes the named command. Note that this will only remove Commander-registered commands. Adds a new command with the given Returns an absolute version of the Returns the "basename," or the last part of the provided Changes Hilbish's directory to Returns the directory part of Match all files based on the provided Takes any list of paths and joins them based on the operating system's path separator. Takes any list of paths and joins them based on the operating system's path separator. Creates a new directory with the provided Returns a list of all files and directories in the provided path. Returns a list of all files and directories in the provided path. Sets an alias, with a name of Sets an alias, with a name of Appends the provided dir to the command path ( Appends the provided dir to the command path (Parameters
string
*name*
-The name of the hook.function
*cb*
+Parameters
string
name
+The name of the hook.function
cb
The function that will be called when the hook is thrown.Example
bait.catch('hilbish.exit', function()
print 'Goodbye Hilbish!'
end)
@@ -58,8 +58,8 @@ bait.catchOnce(name, cb)
-
Parameters
string
*name*
-The name of the eventfunction
*cb*
+Parameters
string
name
+The name of the eventfunction
cb
The function that will be called when the event is thrown.
name
. Parameters
string
*name*
+name
. Parameters
string
name
The name of the hook
@@ -77,8 +77,8 @@ bait.release(name, catcher)
catcher
for the event with name
.
For this to work, catcher
has to be the same function used to catch
-an event, like one saved to a variable. Parameters
string
*name*
-Name of the event the hook is onfunction
*catcher*
+an event, like one saved to a variable. Parameters
string
name
+Name of the event the hook is onfunction
catcher
Hook function to removeExample
local hookCallback = function() print 'hi' end
bait.catch('event', hookCallback)
@@ -93,8 +93,8 @@ bait.throw(name, ...args)
-
name
with the provided args
. Parameters
string
*name*
-The name of the hook.any
*args*
(This type is variadic. You can pass an infinite amount of parameters with this type.)
+name
with the provided args
. Parameters
string
name
+The name of the hook.any
args (This type is variadic. You can pass an infinite amount of parameters with this type.)
The arguments to pass to the hook.Example
bait.throw('greeting', 'world')
-- This can then be listened to via
diff --git a/versions/new-website/docs/api/commander/index.html b/versions/new-website/docs/api/commander/index.html
index 0a345e8b..173a5cda 100644
--- a/versions/new-website/docs/api/commander/index.html
+++ b/versions/new-website/docs/api/commander/index.html
@@ -41,7 +41,7 @@ commander.deregister(name)
-
Parameters
string
*name*
+Parameters
string
name
Name of the command to remove.
@@ -50,8 +50,8 @@ commander.register(name, cb)
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 commandfunction
*cb*
+it will run the function providing the arguments and sinks. Parameters
string
name
+Name of the commandfunction
cb
Callback to handle command invocationExample
-- When you run the command `hello` in the shell, it will print `Hello world`.
-- If you run it with, for example, `hello Hilbish`, it will print 'Hello Hilbish'
commander.register('hello', function(args, sinks)
diff --git a/versions/new-website/docs/api/fs/index.html b/versions/new-website/docs/api/fs/index.html
index 98fc1ff9..3009acd6 100644
--- a/versions/new-website/docs/api/fs/index.html
+++ b/versions/new-website/docs/api/fs/index.html
@@ -63,7 +63,7 @@ fs.abs(path) -> string
path
.
-This can be used to resolve short paths like ..
to /home/user
. Parameters
string
*path*
+This can be used to resolve short paths like ..
to /home/user
. Parameters
string
path
fs.basename(path) -> string
@@ -71,7 +71,7 @@ fs.basename(path) -> string
path
. If path is empty,
-.
will be returned. Parameters
string
*path*
+.
will be returned. Parameters
string
path
Path to get the base name of.dir
. Parameters
string
dir
Path to change directory to.
@@ -88,7 +88,7 @@ fs.dir(path) -> string
path
. If a file path like
-~/Documents/doc.txt
then this function will return ~/Documents
. Parameters
string
*path*
+~/Documents/doc.txt
then this function will return ~/Documents
. Parameters
string
path
Path to get the directory for.
@@ -97,7 +97,7 @@ fs.glob(pattern) -> matches (table)
pattern
.
-For the syntax' refer to Go's filepath.Match function: https://pkg.go.dev/path/filepath#Match Parameters
string
*pattern*
+For the syntax' refer to Go's filepath.Match function: https://pkg.go.dev/path/filepath#Match Parameters
string
pattern
Pattern to compare files with.Example
--[[
Within a folder that contains the following files:
a.txt
@@ -115,7 +115,7 @@ fs.join(...path) -> string
-
Parameters
string
*path*
(This type is variadic. You can pass an infinite amount of parameters with this type.)
+Parameters
string
path (This type is variadic. You can pass an infinite amount of parameters with this type.)
Paths to join togetherExample
-- This prints the directory for Hilbish's config!
print(fs.join(hilbish.userDir.config, 'hilbish'))
-- -> '/home/user/.config/hilbish' on Linux
@@ -127,8 +127,8 @@ fs.mkdir(name, recursive)
name
.
-With recursive
, mkdir will create parent directories. Parameters
string
*name*
-Name of the directoryboolean
*recursive*
+With recursive
, mkdir will create parent directories. Parameters
string
name
+Name of the directoryboolean
recursive
Whether to create parent directories for the provided nameExample
-- This will create the directory foo, then create the directory bar in the
-- foo directory. If recursive is false in this case, it will fail.
fs.mkdir('./foo/bar', true)
@@ -147,7 +147,7 @@ fs.readdir(path) -> table[string]
-
Parameters
string
*dir*
+Parameters
string
dir
fs.stat(path) -> {}
@@ -159,7 +159,7 @@ The returned table contains the following values:
name (string) - Name of the path
size (number) - Size of the path in bytes
mode (string) - Unix permission mode in an octal format string (with leading 0)
-isDir (boolean) - If the path is a directory
Parameters
string
*path*
Example
local inspect = require 'inspect'
+isDir (boolean) - If the path is a directory
Parameters
string
path Example
local inspect = require 'inspect'
local stat = fs.stat '~'
print(inspect(stat))
diff --git a/versions/new-website/docs/api/hilbish/index.html b/versions/new-website/docs/api/hilbish/index.html
index 2bf7dbfc..c6324e2f 100644
--- a/versions/new-website/docs/api/hilbish/index.html
+++ b/versions/new-website/docs/api/hilbish/index.html
@@ -75,8 +75,8 @@ hilbish.alias(cmd, orig)
-
cmd
to another command. Parameters
string
*cmd*
-Name of the aliasstring
*orig*
+cmd
to another command. Parameters
string
cmd
+Name of the aliasstring
orig
Command that will be aliasedExample
-- With this, "ga file" will turn into "git add file"
hilbish.alias('ga', 'git add')
@@ -90,7 +90,7 @@ hilbish.appendPath(dir)
-
$PATH
) Parameters
string|table
*dir*
+$PATH
) Parameters
string|table
dir
Directory (or directories) to append to pathExample
hilbish.appendPath '~/go/bin'
-- Will add ~/go/bin to the command path.
@@ -110,7 +110,7 @@ hilbish.complete(scope, cb)
A
scope
is expected to be command.<cmd>
,
replacing <cmd> with the name of the command (for example command.git
).
The documentation for completions, under Features/Completions or doc completions
-provides more details.
string
*scope*
function
*cb*
-- This is a very simple example. Read the full doc for completions for details.
+provides more details. Parameters
string
scope
function
cb
Example
-- This is a very simple example. Read the full doc for completions for details.
hilbish.complete('command.sudo', function(query, ctx, fields)
if #fields == 0 then
-- complete for commands
@@ -148,7 +148,7 @@ hilbish.exec(cmd)
Replaces the currently running Hilbish instance with the supplied command.
-This can be used to do an in-place restart.
Parameters
string
*cmd*
+This can be used to do an in-place restart. Parameters
string
cmd
hilbish.goro(fn)
@@ -158,7 +158,7 @@ hilbish.goro(fn)
Puts fn
in a Goroutine.
This can be used to run any function in another thread at the same time as other Lua code.
*NOTE: THIS FUNCTION MAY CRASH HILBISH IF OUTSIDE VARIABLES ARE ACCESSED.*
-*This is a limitation of the Lua runtime.*
Parameters
function
*fn*
+*This is a limitation of the Lua runtime.* Parameters
function
fn
hilbish.highlighter(line)
@@ -169,7 +169,7 @@ hilbish.highlighter(line)
This is mainly for syntax highlighting, but in reality could set the input
of the prompt to display anything. The callback is passed the current line
and is expected to return a line that will be used as the input display.
-Note that to set a highlighter, one has to override this function. Parameters
string
*line*
Example
--This code will highlight all double quoted strings in green.
+Note that to set a highlighter, one has to override this function. Parameters
string
line
Example
--This code will highlight all double quoted strings in green.
function hilbish.highlighter(line)
return line:gsub('"%w+"', function(c) return lunacolors.green(c) end)
@@ -186,7 +186,7 @@ hilbish.hinter(line, pos)
determine what text to use as an inline hint. It is passed the current
line and cursor position. It is expected to return a string which is used
as the text for the hint. This is by default a shim. To set hints,
-override this function with your custom handler. Parameters
string
*line*
number
*pos*
+override this function with your custom handler.
Parameters
string
line
number
pos
Position of cursor in line. Usually equals string.len(line)
Example
-- this will display "hi" after the cursor in a dimmed color.
function hilbish.hinter(line, pos)
return 'hi'
@@ -200,7 +200,7 @@ hilbish.inputMode(mode)
Sets the input mode for Hilbish's line reader.
emacs
is the default. Setting it to vim
changes behavior of input to be
-Vim-like with modes and Vim keybinds.
Parameters
string
*mode*
+Vim-like with modes and Vim keybinds.
Parameters
string
mode
Can be set to either emacs
or vim
@@ -209,7 +209,7 @@ hilbish.interval(cb, time) -> @Timer
Runs the cb
function every specified amount of time
.
-This creates a timer that ticking immediately.
Parameters
function
*cb*
number
*time*
+This creates a timer that ticking immediately.
Parameters
function
cb
number
time
Time in milliseconds.
@@ -218,7 +218,7 @@ hilbish.multiprompt(str)
Changes the text prompt when Hilbish asks for more input.
-This will show up when text is incomplete, like a missing quote
Parameters
string
*str*
Example
--[[
+This will show up when text is incomplete, like a missing quote Parameters
string
str
Example
--[[
imagine this is your text input:
user ~ ∆ echo "hey
@@ -240,7 +240,7 @@ hilbish.prependPath(dir)
-
Prepends dir
to $PATH.
Parameters
string
*dir*
+Prepends dir
to $PATH.
Parameters
string
dir
hilbish.prompt(str, typ)
@@ -252,7 +252,7 @@ There are a few verbs that can be used in the prompt text.
These will be formatted and replaced with the appropriate values.
%d
- Current working directory
%u
- Name of current user
-%h
- Hostname of device Parameters
string
*str*
string
*typ?*
+%h
- Hostname of device
Parameters
string
str
string
typ?
Type of prompt, being left or right. Left by default.
Example
-- the default hilbish prompt without color
hilbish.prompt '%u %d ∆'
-- or something of old:
@@ -267,7 +267,7 @@ hilbish.read(prompt) -> input (string)
Read input from the user, using Hilbish's line editor/input reader.
This is a separate instance from the one Hilbish actually uses.
-Returns input
, will be nil if Ctrl-D is pressed, or an error occurs.
Parameters
string
*prompt?*
+Returns input
, will be nil if Ctrl-D is pressed, or an error occurs.
Parameters
string
prompt?
Text to print before input, can be empty.
@@ -276,7 +276,7 @@ hilbish.timeout(cb, time) -> @Timer
Executed the cb
function after a period of time
.
-This creates a Timer that starts ticking immediately.
Parameters
function
*cb*
number
*time*
+This creates a Timer that starts ticking immediately.
Parameters
function
cb
number
time
Time to run in milliseconds.
@@ -285,7 +285,7 @@ hilbish.which(name) -> string
Checks if name
is a valid command.
-Will return the path of the binary, or a basename if it's a commander.
Parameters
string
*name*
Types
Sink
A sink is a structure that has input and/or output to/from a desination.
Methods
autoFlush(auto)
Sets/toggles the option of automatically flushing output.
+Will return the path of the binary, or a basename if it's a commander.
Parameters
string
name
Types
Sink
A sink is a structure that has input and/or output to/from a desination.
Methods
autoFlush(auto)
Sets/toggles the option of automatically flushing output.
A call with no argument will toggle the value.
flush()
Flush writes all buffered input to the sink.
read() -> string
Reads a liine of input from the sink.
readAll() -> string
Reads all input from the sink.
write(str)
Writes data to a sink.
writeln(str)
Writes data to a sink with a newline at the end.