mirror of https://github.com/Hilbis/Hilbish
Compare commits
8 Commits
6edf1c7733
...
0dfed4d7aa
Author | SHA1 | Date |
---|---|---|
sammyette | 0dfed4d7aa | |
sammyette | 0de305a9a3 | |
sammyette | d3a9585017 | |
sammyette | 884bc1fd36 | |
sammyette | b0e05d4b16 | |
sammyette | 9d5f5abef4 | |
sammyette | a0513c0a05 | |
sammyette | 1d64a57e24 |
10
CHANGELOG.md
10
CHANGELOG.md
|
@ -21,6 +21,16 @@ completed.
|
||||||
- Using this also brings enhancements to the `doc` command like easy
|
- Using this also brings enhancements to the `doc` command like easy
|
||||||
navigation of neighboring doc files.
|
navigation of neighboring doc files.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Documentation for EVERYTHING has been improved, with more
|
||||||
|
information added, code example, parameter details, etc.
|
||||||
|
You can see the improvements!
|
||||||
|
- Documentation has gotten an uplift in the `doc` command.
|
||||||
|
This includes:
|
||||||
|
- Proper highlighting of code
|
||||||
|
- Paging (via Greenhouse)
|
||||||
|
- Highlighting more markdown things
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Fix infinite loop when navigating history without any history. [#252](https://github.com/Rosettea/Hilbish/issues/252)
|
- Fix infinite loop when navigating history without any history. [#252](https://github.com/Rosettea/Hilbish/issues/252)
|
||||||
- Return the prefix when calling `hilbish.completions.call`. [#219](https://github.com/Rosettea/Hilbish/issues/219)
|
- Return the prefix when calling `hilbish.completions.call`. [#219](https://github.com/Rosettea/Hilbish/issues/219)
|
||||||
|
|
|
@ -554,11 +554,11 @@ func main() {
|
||||||
|
|
||||||
`, htmlSig, dps.FuncName))
|
`, htmlSig, dps.FuncName))
|
||||||
for _, doc := range dps.Doc {
|
for _, doc := range dps.Doc {
|
||||||
if !strings.HasPrefix(doc, "---") {
|
if !strings.HasPrefix(doc, "---") && doc != "" {
|
||||||
f.WriteString(doc + " \n")
|
f.WriteString(doc + " \n")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
f.WriteString("#### Parameters\n")
|
f.WriteString("\n#### Parameters\n")
|
||||||
if len(dps.Params) == 0 {
|
if len(dps.Params) == 0 {
|
||||||
f.WriteString("This function has no parameters. \n")
|
f.WriteString("This function has no parameters. \n")
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,17 +17,53 @@ for _, fname in ipairs(files) do
|
||||||
pieces[mod] = {}
|
pieces[mod] = {}
|
||||||
|
|
||||||
local docPiece = {}
|
local docPiece = {}
|
||||||
|
local lines = {}
|
||||||
|
local lineno = 0
|
||||||
for line in f:lines() do
|
for line in f:lines() do
|
||||||
|
lineno = lineno + 1
|
||||||
|
lines[lineno] = line
|
||||||
|
|
||||||
if line == header then goto continue2 end
|
if line == header then goto continue2 end
|
||||||
if not line:match(emmyPattern) then
|
if not line:match(emmyPattern) then
|
||||||
if line:match '^function' then
|
if line:match '^function' then
|
||||||
local pattern = (string.format('^function %s%%.', mod) .. '(%w+)')
|
local pattern = (string.format('^function %s%%.', mod) .. '(%w+)')
|
||||||
local funcName = line:match(pattern)
|
local funcName = line:match(pattern)
|
||||||
if not funcName then goto continue2 end
|
if not funcName then goto continue2 end
|
||||||
print(line)
|
|
||||||
print(pattern)
|
local dps = {
|
||||||
print(funcName)
|
description = {},
|
||||||
pieces[iface][funcName] = docPiece
|
params = {}
|
||||||
|
}
|
||||||
|
|
||||||
|
local offset = 1
|
||||||
|
while true do
|
||||||
|
local prev = lines[lineno - offset]
|
||||||
|
|
||||||
|
local docline = prev:match '^%-+ (.+)'
|
||||||
|
if docline then
|
||||||
|
local emmy = docline:match '@(%w+)'
|
||||||
|
local cut = 0
|
||||||
|
|
||||||
|
if emmy then cut = emmy:len() + 3 end
|
||||||
|
local emmythings = string.split(docline:sub(cut), ' ')
|
||||||
|
|
||||||
|
if emmy then
|
||||||
|
if emmy == 'param' then
|
||||||
|
table.insert(dps.params, 1, {
|
||||||
|
name = emmythings[1],
|
||||||
|
type = emmythings[2]
|
||||||
|
})
|
||||||
|
end
|
||||||
|
else
|
||||||
|
table.insert(dps.description, 1, docline)
|
||||||
|
end
|
||||||
|
offset = offset + 1
|
||||||
|
else
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
pieces[mod][funcName] = dps
|
||||||
end
|
end
|
||||||
docPiece = {}
|
docPiece = {}
|
||||||
goto continue2
|
goto continue2
|
||||||
|
@ -39,20 +75,57 @@ for _, fname in ipairs(files) do
|
||||||
::continue::
|
::continue::
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local header = [[---
|
||||||
|
title: %s %s
|
||||||
|
description: %s
|
||||||
|
layout: doc
|
||||||
|
menu:
|
||||||
|
docs:
|
||||||
|
parent: "Nature"
|
||||||
|
---
|
||||||
|
|
||||||
|
]]
|
||||||
|
|
||||||
for iface, dps in pairs(pieces) do
|
for iface, dps in pairs(pieces) do
|
||||||
local mod = iface:match '(%w+)%.' or 'nature'
|
local mod = iface:match '(%w+)%.' or 'nature'
|
||||||
local path = string.format('luadocs/api/%s/%s.md', mod, iface)
|
local path = string.format('docs/%s/%s.md', mod, iface)
|
||||||
local f <close> = io.open(path, 'a+')
|
fs.mkdir(fs.dir(path), true)
|
||||||
|
local f <close> = io.open(path, 'w')
|
||||||
|
f:write(string.format(header, 'Module', iface, 'No description.'))
|
||||||
print(f)
|
print(f)
|
||||||
|
|
||||||
print(mod, path)
|
print(mod, path)
|
||||||
fs.mkdir(fs.dir(path), true)
|
|
||||||
|
|
||||||
for func, docs in pairs(dps) do
|
for func, docs in pairs(dps) do
|
||||||
|
f:write(string.format('<hr>\n<div id=\'%s\'>', func))
|
||||||
|
local sig = string.format('%s.%s(', iface, func)
|
||||||
|
for idx, param in ipairs(docs.params) do
|
||||||
|
sig = sig .. ((param.name:gsub('%?$', '')))
|
||||||
|
if idx ~= #docs.params then sig = sig .. ', ' end
|
||||||
|
end
|
||||||
|
sig = sig .. ')'
|
||||||
|
f:write(string.format([[
|
||||||
|
<h4 class='heading'>
|
||||||
|
%s
|
||||||
|
<a href="#%s" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
]], sig, func))
|
||||||
|
|
||||||
|
f:write(table.concat(docs.description, '\n') .. '\n')
|
||||||
|
f:write '#### Parameters\n'
|
||||||
|
if #docs.params == 0 then
|
||||||
|
f:write 'This function has no parameters. \n'
|
||||||
|
end
|
||||||
|
for _, param in ipairs(docs.params) do
|
||||||
|
f:write(string.format('`%s` **`%s`**\n', param.name:gsub('%?$', ''), param.type))
|
||||||
|
end
|
||||||
|
--[[
|
||||||
local params = table.filter(docs, function(t)
|
local params = table.filter(docs, function(t)
|
||||||
return t:match '^%-%-%- @param'
|
return t:match '^%-%-%- @param'
|
||||||
end)
|
end)
|
||||||
f:write(string.format('## %s(', func))
|
|
||||||
for i, str in ipairs(params) do
|
for i, str in ipairs(params) do
|
||||||
if i ~= 1 then
|
if i ~= 1 then
|
||||||
f:write ', '
|
f:write ', '
|
||||||
|
@ -66,7 +139,8 @@ for iface, dps in pairs(pieces) do
|
||||||
f:write(str:match '^%-%-%- (.+)' .. '\n')
|
f:write(str:match '^%-%-%- (.+)' .. '\n')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
f:write('\n')
|
]]--
|
||||||
|
f:write('</div>')
|
||||||
|
f:write('\n\n')
|
||||||
end
|
end
|
||||||
f:flush()
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -51,8 +51,7 @@ bait.catch(name, cb)
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
Catches an event. This function can be used to act on events.
|
Catches an event. This function can be used to act on events.
|
||||||
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`string` **`name`**
|
`string` **`name`**
|
||||||
The name of the hook.
|
The name of the hook.
|
||||||
|
@ -78,6 +77,7 @@ bait.catchOnce(name, cb)
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
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.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`string` **`name`**
|
`string` **`name`**
|
||||||
The name of the event
|
The name of the event
|
||||||
|
@ -97,6 +97,7 @@ bait.hooks(name) -> table
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
Returns a list of callbacks that are hooked on an event with the corresponding `name`.
|
Returns a list of callbacks that are hooked on an event with the corresponding `name`.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`string` **`name`**
|
`string` **`name`**
|
||||||
The name of the function
|
The name of the function
|
||||||
|
@ -115,8 +116,7 @@ bait.release(name, catcher)
|
||||||
Removes the `catcher` for the event with `name`.
|
Removes the `catcher` for the event with `name`.
|
||||||
For this to work, `catcher` has to be the same function used to catch
|
For this to work, `catcher` has to be the same function used to catch
|
||||||
an event, like one saved to a variable.
|
an event, like one saved to a variable.
|
||||||
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`string` **`name`**
|
`string` **`name`**
|
||||||
Name of the event the hook is on
|
Name of the event the hook is on
|
||||||
|
@ -146,8 +146,7 @@ bait.throw(name, ...args)
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
Throws a hook with `name` with the provided `args`.
|
Throws a hook with `name` with the provided `args`.
|
||||||
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`string` **`name`**
|
`string` **`name`**
|
||||||
The name of the hook.
|
The name of the hook.
|
||||||
|
|
|
@ -52,6 +52,7 @@ commander.deregister(name)
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
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.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`string` **`name`**
|
`string` **`name`**
|
||||||
Name of the command to remove.
|
Name of the command to remove.
|
||||||
|
@ -69,8 +70,7 @@ commander.register(name, cb)
|
||||||
|
|
||||||
Adds a new command with the given `name`. When Hilbish has to run a command with a name,
|
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.
|
it will run the function providing the arguments and sinks.
|
||||||
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`string` **`name`**
|
`string` **`name`**
|
||||||
Name of the command
|
Name of the command
|
||||||
|
|
|
@ -42,6 +42,7 @@ fs.abs(path) -> string
|
||||||
|
|
||||||
Returns an absolute version of the `path`.
|
Returns an absolute version of the `path`.
|
||||||
This can be used to resolve short paths like `..` to `/home/user`.
|
This can be used to resolve short paths like `..` to `/home/user`.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`string` **`path`**
|
`string` **`path`**
|
||||||
|
|
||||||
|
@ -59,6 +60,7 @@ fs.basename(path) -> string
|
||||||
|
|
||||||
Returns the "basename," or the last part of the provided `path`. If path is empty,
|
Returns the "basename," or the last part of the provided `path`. If path is empty,
|
||||||
`.` will be returned.
|
`.` will be returned.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`string` **`path`**
|
`string` **`path`**
|
||||||
Path to get the base name of.
|
Path to get the base name of.
|
||||||
|
@ -75,6 +77,7 @@ fs.cd(dir)
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
Changes Hilbish's directory to `dir`.
|
Changes Hilbish's directory to `dir`.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`string` **`dir`**
|
`string` **`dir`**
|
||||||
Path to change directory to.
|
Path to change directory to.
|
||||||
|
@ -92,6 +95,7 @@ fs.dir(path) -> string
|
||||||
|
|
||||||
Returns the directory part of `path`. If a file path like
|
Returns the directory part of `path`. If a file path like
|
||||||
`~/Documents/doc.txt` then this function will return `~/Documents`.
|
`~/Documents/doc.txt` then this function will return `~/Documents`.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`string` **`path`**
|
`string` **`path`**
|
||||||
Path to get the directory for.
|
Path to get the directory for.
|
||||||
|
@ -109,8 +113,7 @@ fs.glob(pattern) -> matches (table)
|
||||||
|
|
||||||
Match all files based on the provided `pattern`.
|
Match all files based on the provided `pattern`.
|
||||||
For the syntax' refer to Go's filepath.Match function: https://pkg.go.dev/path/filepath#Match
|
For the syntax' refer to Go's filepath.Match function: https://pkg.go.dev/path/filepath#Match
|
||||||
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`string` **`pattern`**
|
`string` **`pattern`**
|
||||||
Pattern to compare files with.
|
Pattern to compare files with.
|
||||||
|
@ -140,8 +143,7 @@ fs.join(...path) -> string
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
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.
|
||||||
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`string` **`path`** (This type is variadic. You can pass an infinite amount of parameters with this type.)
|
`string` **`path`** (This type is variadic. You can pass an infinite amount of parameters with this type.)
|
||||||
Paths to join together
|
Paths to join together
|
||||||
|
@ -165,10 +167,10 @@ fs.mkdir(name, recursive)
|
||||||
|
|
||||||
Creates a new directory with the provided `name`.
|
Creates a new directory with the provided `name`.
|
||||||
With `recursive`, mkdir will create parent directories.
|
With `recursive`, mkdir will create parent directories.
|
||||||
|
|
||||||
-- This will create the directory foo, then create the directory bar in the
|
-- 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.
|
-- foo directory. If recursive is false in this case, it will fail.
|
||||||
fs.mkdir('./foo/bar', true)
|
fs.mkdir('./foo/bar', true)
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`string` **`name`**
|
`string` **`name`**
|
||||||
Name of the directory
|
Name of the directory
|
||||||
|
@ -192,6 +194,7 @@ fs.readdir(path) -> table[string]
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
Returns a list of all files and directories in the provided path.
|
Returns a list of all files and directories in the provided path.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`string` **`dir`**
|
`string` **`dir`**
|
||||||
|
|
||||||
|
@ -213,8 +216,7 @@ name (string) - Name of the path
|
||||||
size (number) - Size of the path in bytes
|
size (number) - Size of the path in bytes
|
||||||
mode (string) - Unix permission mode in an octal format string (with leading 0)
|
mode (string) - Unix permission mode in an octal format string (with leading 0)
|
||||||
isDir (boolean) - If the path is a directory
|
isDir (boolean) - If the path is a directory
|
||||||
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`string` **`path`**
|
`string` **`path`**
|
||||||
|
|
||||||
|
|
|
@ -56,8 +56,7 @@ hilbish.alias(cmd, orig)
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
Sets an alias, with a name of `cmd` to another command.
|
Sets an alias, with a name of `cmd` to another command.
|
||||||
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`string` **`cmd`**
|
`string` **`cmd`**
|
||||||
Name of the alias
|
Name of the alias
|
||||||
|
@ -86,8 +85,7 @@ hilbish.appendPath(dir)
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
Appends the provided dir to the command path (`$PATH`)
|
Appends the provided dir to the command path (`$PATH`)
|
||||||
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`string|table` **`dir`**
|
`string|table` **`dir`**
|
||||||
Directory (or directories) to append to path
|
Directory (or directories) to append to path
|
||||||
|
@ -119,6 +117,7 @@ A `scope` is currently only expected to be `command.<cmd>`,
|
||||||
replacing <cmd> with the name of the command (for example `command.git`).
|
replacing <cmd> with the name of the command (for example `command.git`).
|
||||||
The documentation for completions, under Features/Completions or `doc completions`
|
The documentation for completions, under Features/Completions or `doc completions`
|
||||||
provides more details.
|
provides more details.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`string` **`scope`**
|
`string` **`scope`**
|
||||||
|
|
||||||
|
@ -138,6 +137,7 @@ hilbish.cwd() -> string
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
Returns the current directory of the shell
|
Returns the current directory of the shell
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
</div>
|
</div>
|
||||||
|
@ -153,6 +153,7 @@ hilbish.exec(cmd)
|
||||||
|
|
||||||
Replaces the currently running Hilbish instance with the supplied command.
|
Replaces the currently running Hilbish instance with the supplied command.
|
||||||
This can be used to do an in-place restart.
|
This can be used to do an in-place restart.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`string` **`cmd`**
|
`string` **`cmd`**
|
||||||
|
|
||||||
|
@ -171,6 +172,7 @@ hilbish.goro(fn)
|
||||||
Puts `fn` in a Goroutine.
|
Puts `fn` in a Goroutine.
|
||||||
This can be used to run any function in another thread.
|
This can be used to run any function in another thread.
|
||||||
**NOTE: THIS FUNCTION MAY CRASH HILBISH IF OUTSIDE VARIABLES ARE ACCESSED.**
|
**NOTE: THIS FUNCTION MAY CRASH HILBISH IF OUTSIDE VARIABLES ARE ACCESSED.**
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`function` **`fn`**
|
`function` **`fn`**
|
||||||
|
|
||||||
|
@ -191,7 +193,7 @@ 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
|
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.
|
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.
|
Note that to set a highlighter, one has to override this function.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`string` **`line`**
|
`string` **`line`**
|
||||||
|
|
||||||
|
@ -219,8 +221,7 @@ 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
|
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,
|
as the text for the hint. This is by default a shim. To set hints,
|
||||||
override this function with your custom handler.
|
override this function with your custom handler.
|
||||||
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`string` **`line`**
|
`string` **`line`**
|
||||||
|
|
||||||
|
@ -249,6 +250,7 @@ hilbish.inputMode(mode)
|
||||||
Sets the input mode for Hilbish's line reader. Accepts either emacs or vim.
|
Sets the input mode for Hilbish's line reader. Accepts either emacs or vim.
|
||||||
`emacs` is the default. Setting it to `vim` changes behavior of input to be
|
`emacs` is the default. Setting it to `vim` changes behavior of input to be
|
||||||
Vim-like with modes and Vim keybinds.
|
Vim-like with modes and Vim keybinds.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`string` **`mode`**
|
`string` **`mode`**
|
||||||
|
|
||||||
|
@ -266,6 +268,7 @@ hilbish.interval(cb, time) -> <a href="/Hilbish/docs/api/hilbish/hilbish.timers/
|
||||||
|
|
||||||
Runs the `cb` function every `time` milliseconds.
|
Runs the `cb` function every `time` milliseconds.
|
||||||
This creates a timer that starts immediately.
|
This creates a timer that starts immediately.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`function` **`cb`**
|
`function` **`cb`**
|
||||||
|
|
||||||
|
@ -286,8 +289,7 @@ hilbish.multiprompt(str)
|
||||||
|
|
||||||
Changes the text prompt when Hilbish asks for more input.
|
Changes the text prompt when Hilbish asks for more input.
|
||||||
This will show up when text is incomplete, like a missing quote
|
This will show up when text is incomplete, like a missing quote
|
||||||
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`string` **`str`**
|
`string` **`str`**
|
||||||
|
|
||||||
|
@ -322,6 +324,7 @@ hilbish.prependPath(dir)
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
Prepends `dir` to $PATH.
|
Prepends `dir` to $PATH.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`string` **`dir`**
|
`string` **`dir`**
|
||||||
|
|
||||||
|
@ -343,7 +346,7 @@ These will be formatted and replaced with the appropriate values.
|
||||||
`%d` - Current working directory
|
`%d` - Current working directory
|
||||||
`%u` - Name of current user
|
`%u` - Name of current user
|
||||||
`%h` - Hostname of device
|
`%h` - Hostname of device
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`string` **`str`**
|
`string` **`str`**
|
||||||
|
|
||||||
|
@ -373,6 +376,7 @@ hilbish.read(prompt) -> input (string)
|
||||||
Read input from the user, using Hilbish's line editor/input reader.
|
Read input from the user, using Hilbish's line editor/input reader.
|
||||||
This is a separate instance from the one Hilbish actually uses.
|
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 (which shouldn't happen).
|
Returns `input`, will be nil if ctrl + d is pressed, or an error occurs (which shouldn't happen).
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`string` **`prompt?`**
|
`string` **`prompt?`**
|
||||||
|
|
||||||
|
@ -389,6 +393,7 @@ hilbish.run(cmd, returnOut) -> exitCode (number), stdout (string), stderr (strin
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
Runs `cmd` in Hilbish's shell script interpreter.
|
Runs `cmd` in Hilbish's shell script interpreter.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`string` **`cmd`**
|
`string` **`cmd`**
|
||||||
|
|
||||||
|
@ -412,6 +417,7 @@ Hilbish wll try to run input as Lua and/or sh or only do one of either.
|
||||||
Accepted values for mode are hybrid (the default), hybridRev (sh first then Lua),
|
Accepted values for mode are hybrid (the default), hybridRev (sh first then Lua),
|
||||||
sh, and lua. It also accepts a function, to which if it is passed one
|
sh, and lua. It also accepts a function, to which if it is passed one
|
||||||
will call it to execute user input instead.
|
will call it to execute user input instead.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`string|function` **`mode`**
|
`string|function` **`mode`**
|
||||||
|
|
||||||
|
@ -429,6 +435,7 @@ hilbish.timeout(cb, time) -> <a href="/Hilbish/docs/api/hilbish/hilbish.timers/#
|
||||||
|
|
||||||
Runs the `cb` function after `time` in milliseconds.
|
Runs the `cb` function after `time` in milliseconds.
|
||||||
This creates a Timer that starts immediately.
|
This creates a Timer that starts immediately.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`function` **`cb`**
|
`function` **`cb`**
|
||||||
|
|
||||||
|
@ -449,6 +456,7 @@ hilbish.which(name) -> string
|
||||||
|
|
||||||
Checks if `name` is a valid command.
|
Checks if `name` is a valid command.
|
||||||
Will return the path of the binary, or a basename if it's a commander.
|
Will return the path of the binary, or a basename if it's a commander.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`string` **`name`**
|
`string` **`name`**
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ hilbish.aliases.add(alias, cmd)
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
This is an alias (ha) for the [hilbish.alias](../#alias) function.
|
This is an alias (ha) for the [hilbish.alias](../#alias) function.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
</div>
|
</div>
|
||||||
|
@ -42,6 +43,7 @@ hilbish.aliases.delete(name)
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
Removes an alias.
|
Removes an alias.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`string` **`name`**
|
`string` **`name`**
|
||||||
|
|
||||||
|
@ -58,8 +60,7 @@ hilbish.aliases.list() -> table[string, string]
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
Get a table of all aliases, with string keys as the alias and the value as the command.
|
Get a table of all aliases, with string keys as the alias and the value as the command.
|
||||||
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
#### Example
|
#### Example
|
||||||
|
@ -81,6 +82,7 @@ hilbish.aliases.resolve(alias) -> string?
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
Resolves an alias to its original command. Will thrown an error if the alias doesn't exist.
|
Resolves an alias to its original command. Will thrown an error if the alias doesn't exist.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`string` **`alias`**
|
`string` **`alias`**
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,7 @@ hilbish.completion.bins(query, ctx, fields) -> entries (table), prefix (string)
|
||||||
|
|
||||||
Return binaries/executables based on the provided parameters.
|
Return binaries/executables based on the provided parameters.
|
||||||
This function is meant to be used as a helper in a command completion handler.
|
This function is meant to be used as a helper in a command completion handler.
|
||||||
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`string` **`query`**
|
`string` **`query`**
|
||||||
|
|
||||||
|
@ -73,6 +72,7 @@ hilbish.completion.call(name, query, ctx, fields) -> completionGroups (table), p
|
||||||
Calls a completer function. This is mainly used to call a command completer, which will have a `name`
|
Calls a completer function. This is mainly used to call a command completer, which will have a `name`
|
||||||
in the form of `command.name`, example: `command.git`.
|
in the form of `command.name`, example: `command.git`.
|
||||||
You can check the Completions doc or `doc completions` for info on the `completionGroups` return value.
|
You can check the Completions doc or `doc completions` for info on the `completionGroups` return value.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`string` **`name`**
|
`string` **`name`**
|
||||||
|
|
||||||
|
@ -99,6 +99,7 @@ hilbish.completion.files(query, ctx, fields) -> entries (table), prefix (string)
|
||||||
|
|
||||||
Returns file matches based on the provided parameters.
|
Returns file matches based on the provided parameters.
|
||||||
This function is meant to be used as a helper in a command completion handler.
|
This function is meant to be used as a helper in a command completion handler.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`string` **`query`**
|
`string` **`query`**
|
||||||
|
|
||||||
|
@ -123,8 +124,7 @@ hilbish.completion.handler(line, pos)
|
||||||
This function contains the general completion handler for Hilbish. This function handles
|
This function contains the general completion handler for Hilbish. This function handles
|
||||||
completion of everything, which includes calling other command handlers, binaries, and files.
|
completion of everything, which includes calling other command handlers, binaries, and files.
|
||||||
This function can be overriden to supply a custom handler. Note that alias resolution is required to be done in this function.
|
This function can be overriden to supply a custom handler. Note that alias resolution is required to be done in this function.
|
||||||
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`string` **`line`**
|
`string` **`line`**
|
||||||
The current Hilbish command line
|
The current Hilbish command line
|
||||||
|
|
|
@ -30,6 +30,7 @@ hilbish.editor.getLine() -> string
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
Returns the current input line.
|
Returns the current input line.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
</div>
|
</div>
|
||||||
|
@ -44,6 +45,7 @@ hilbish.editor.getVimRegister(register) -> string
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
Returns the text that is at the register.
|
Returns the text that is at the register.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`string` **`register`**
|
`string` **`register`**
|
||||||
|
|
||||||
|
@ -60,6 +62,7 @@ hilbish.editor.insert(text)
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
Inserts text into the Hilbish command line.
|
Inserts text into the Hilbish command line.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`string` **`text`**
|
`string` **`text`**
|
||||||
|
|
||||||
|
@ -76,6 +79,7 @@ hilbish.editor.getChar() -> string
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
Reads a keystroke from the user. This is in a format of something like Ctrl-L.
|
Reads a keystroke from the user. This is in a format of something like Ctrl-L.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
</div>
|
</div>
|
||||||
|
@ -90,6 +94,7 @@ hilbish.editor.setVimRegister(register, text)
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
Sets the vim register at `register` to hold the passed text.
|
Sets the vim register at `register` to hold the passed text.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`string` **`text`**
|
`string` **`text`**
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@ hilbish.history.add(cmd)
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
Adds a command to the history.
|
Adds a command to the history.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`string` **`cmd`**
|
`string` **`cmd`**
|
||||||
|
|
||||||
|
@ -47,6 +48,7 @@ hilbish.history.all() -> table
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
Retrieves all history as a table.
|
Retrieves all history as a table.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
</div>
|
</div>
|
||||||
|
@ -61,6 +63,7 @@ hilbish.history.clear()
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
Deletes all commands from the history.
|
Deletes all commands from the history.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
</div>
|
</div>
|
||||||
|
@ -75,6 +78,7 @@ hilbish.history.get(index)
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
Retrieves a command from the history based on the `index`.
|
Retrieves a command from the history based on the `index`.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`number` **`index`**
|
`number` **`index`**
|
||||||
|
|
||||||
|
@ -91,6 +95,7 @@ hilbish.history.size() -> number
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
Returns the amount of commands in the history.
|
Returns the amount of commands in the history.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -34,8 +34,7 @@ hilbish.jobs.add(cmdstr, args, execPath)
|
||||||
|
|
||||||
Creates a new job. This function does not run the job. This function is intended to be
|
Creates a new job. This function does not run the job. This function is intended to be
|
||||||
used by runners, but can also be used to create jobs via Lua. Commanders cannot be ran as jobs.
|
used by runners, but can also be used to create jobs via Lua. Commanders cannot be ran as jobs.
|
||||||
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`string` **`cmdstr`**
|
`string` **`cmdstr`**
|
||||||
String that a user would write for the job
|
String that a user would write for the job
|
||||||
|
@ -62,6 +61,7 @@ hilbish.jobs.all() -> table[<a href="/Hilbish/docs/api/hilbish/hilbish.jobs/#job
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
Returns a table of all job objects.
|
Returns a table of all job objects.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
</div>
|
</div>
|
||||||
|
@ -76,6 +76,7 @@ hilbish.jobs.disown(id)
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
Disowns a job. This simply deletes it from the list of jobs without stopping it.
|
Disowns a job. This simply deletes it from the list of jobs without stopping it.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`number` **`id`**
|
`number` **`id`**
|
||||||
|
|
||||||
|
@ -92,6 +93,7 @@ hilbish.jobs.get(id) -> <a href="/Hilbish/docs/api/hilbish/hilbish.jobs/#job" st
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
Get a job object via its ID.
|
Get a job object via its ID.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
</div>
|
</div>
|
||||||
|
@ -106,6 +108,7 @@ hilbish.jobs.last() -> <a href="/Hilbish/docs/api/hilbish/hilbish.jobs/#job" sty
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
Returns the last added job to the table.
|
Returns the last added job to the table.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -64,6 +64,7 @@ hilbish.module.load(path)
|
||||||
|
|
||||||
Loads a module at the designated `path`.
|
Loads a module at the designated `path`.
|
||||||
It will throw if any error occurs.
|
It will throw if any error occurs.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`string` **`path`**
|
`string` **`path`**
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ This is the same as the `hilbish.runnerMode` function.
|
||||||
It takes a callback, which will be used to execute all interactive input.
|
It takes a callback, which will be used to execute all interactive input.
|
||||||
In normal cases, neither callbacks should be overrided by the user,
|
In normal cases, neither callbacks should be overrided by the user,
|
||||||
as the higher level functions listed below this will handle it.
|
as the higher level functions listed below this will handle it.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`function` **`cb`**
|
`function` **`cb`**
|
||||||
|
|
||||||
|
@ -51,6 +52,7 @@ hilbish.runner.lua(cmd)
|
||||||
|
|
||||||
Evaluates `cmd` as Lua input. This is the same as using `dofile`
|
Evaluates `cmd` as Lua input. This is the same as using `dofile`
|
||||||
or `load`, but is appropriated for the runner interface.
|
or `load`, but is appropriated for the runner interface.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`string` **`cmd`**
|
`string` **`cmd`**
|
||||||
|
|
||||||
|
@ -68,6 +70,7 @@ hilbish.runner.sh(cmd)
|
||||||
|
|
||||||
Runs a command in Hilbish's shell script interpreter.
|
Runs a command in Hilbish's shell script interpreter.
|
||||||
This is the equivalent of using `source`.
|
This is the equivalent of using `source`.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`string` **`cmd`**
|
`string` **`cmd`**
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,7 @@ hilbish.timers.create(type, time, callback) -> <a href="/Hilbish/docs/api/hilbis
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
Creates a timer that runs based on the specified `time`.
|
Creates a timer that runs based on the specified `time`.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`number` **`type`**
|
`number` **`type`**
|
||||||
What kind of timer to create, can either be `hilbish.timers.INTERVAL` or `hilbish.timers.TIMEOUT`
|
What kind of timer to create, can either be `hilbish.timers.INTERVAL` or `hilbish.timers.TIMEOUT`
|
||||||
|
@ -70,6 +71,7 @@ hilbish.timers.get(id) -> <a href="/Hilbish/docs/api/hilbish/hilbish.timers/#tim
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
Retrieves a timer via its ID.
|
Retrieves a timer via its ID.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`number` **`id`**
|
`number` **`id`**
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ terminal.restoreState()
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
Restores the last saved state of the terminal
|
Restores the last saved state of the terminal
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
</div>
|
</div>
|
||||||
|
@ -42,6 +43,7 @@ terminal.saveState()
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
Saves the current state of the terminal.
|
Saves the current state of the terminal.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
</div>
|
</div>
|
||||||
|
@ -56,6 +58,7 @@ terminal.setRaw()
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
Puts the terminal into raw mode.
|
Puts the terminal into raw mode.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
</div>
|
</div>
|
||||||
|
@ -71,6 +74,7 @@ terminal.size()
|
||||||
|
|
||||||
Gets the dimensions of the terminal. Returns a table with `width` and `height`
|
Gets the dimensions of the terminal. Returns a table with `width` and `height`
|
||||||
NOTE: The size refers to the amount of columns and rows of text that can fit in the terminal.
|
NOTE: The size refers to the amount of columns and rows of text that can fit in the terminal.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -0,0 +1,78 @@
|
||||||
|
---
|
||||||
|
title: Options
|
||||||
|
description: Simple customizable options.
|
||||||
|
layout: doc
|
||||||
|
menu:
|
||||||
|
docs:
|
||||||
|
parent: "Features"
|
||||||
|
---
|
||||||
|
|
||||||
|
Opts are simple toggle or value options a user can set in Hilbish.
|
||||||
|
As toggles, there are things like `autocd` or history saving. As values,
|
||||||
|
there is the `motd` which the user can either change to a custom string or disable.
|
||||||
|
|
||||||
|
Opts are accessed from the `hilbish.opts` table. Here they can either
|
||||||
|
be read or modified
|
||||||
|
|
||||||
|
### `autocd`
|
||||||
|
#### Value: `boolean`
|
||||||
|
#### Default: `false`
|
||||||
|
|
||||||
|
The autocd opt makes it so that lone directories attempted to be executed are
|
||||||
|
instead set as the shell's directory.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
```
|
||||||
|
~/Directory
|
||||||
|
∆ ~
|
||||||
|
~
|
||||||
|
∆ Downloads
|
||||||
|
~/Downloads
|
||||||
|
∆ ../Documents
|
||||||
|
~/Documents
|
||||||
|
∆
|
||||||
|
```
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
### `history`
|
||||||
|
#### Value: `boolean`
|
||||||
|
#### Default: `true`
|
||||||
|
Sets whether command history will be saved or not.
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
### `greeting`
|
||||||
|
#### Value: `boolean` or `string`
|
||||||
|
The greeting is the message that Hilbish shows on startup
|
||||||
|
(the one which says Welcome to Hilbish).
|
||||||
|
|
||||||
|
This can be set to either true/false to enable/disable or a custom greeting string.
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
### `motd`
|
||||||
|
#### Value: `boolean`
|
||||||
|
#### Default: `true`
|
||||||
|
The message of the day shows the current major.minor version and
|
||||||
|
includes a small range of things added in the current release.
|
||||||
|
|
||||||
|
This can be set to `false` to disable the message.
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
### `fuzzy`
|
||||||
|
#### Value: `boolean`
|
||||||
|
#### Default: `false`
|
||||||
|
Toggles the functionality of fuzzy history searching, usable
|
||||||
|
via the menu in Ctrl-R. Fuzzy searching is an approximate searching
|
||||||
|
method, which means results that match *closest* will be shown instead
|
||||||
|
of an exact match.
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
### `notifyJobFinish`
|
||||||
|
#### Value: `boolean`
|
||||||
|
#### Default: `true`
|
||||||
|
If this is enabled, when a background job is finished,
|
||||||
|
a [notification](../notifications) will be sent.
|
|
@ -0,0 +1,79 @@
|
||||||
|
---
|
||||||
|
title: Module dirs
|
||||||
|
description: No description.
|
||||||
|
layout: doc
|
||||||
|
menu:
|
||||||
|
docs:
|
||||||
|
parent: "Nature"
|
||||||
|
---
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='setOld'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
dirs.setOld(d)
|
||||||
|
<a href="#setOld" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Sets the old directory string.
|
||||||
|
#### Parameters
|
||||||
|
`d` **`string`**
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='push'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
dirs.push()
|
||||||
|
<a href="#push" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Add `d` to the recent directories list.
|
||||||
|
#### Parameters
|
||||||
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='peak'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
dirs.peak(num)
|
||||||
|
<a href="#peak" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Look at `num` amount of recent directories, starting from the latest.
|
||||||
|
#### Parameters
|
||||||
|
`num` **`number`**
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='pop'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
dirs.pop(num)
|
||||||
|
<a href="#pop" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Remove the specified amount of dirs from the recent directories list.
|
||||||
|
#### Parameters
|
||||||
|
`num` **`number`**
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='recent'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
dirs.recent(idx)
|
||||||
|
<a href="#recent" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Get entry from recent directories list based on index.
|
||||||
|
#### Parameters
|
||||||
|
`idx` **`number`**
|
||||||
|
</div>
|
||||||
|
|
3
exec.go
3
exec.go
|
@ -175,6 +175,9 @@ func runLuaRunner(runr rt.Value, userInput string) (input string, exitCode uint8
|
||||||
runnerRet := term.Get(0)
|
runnerRet := term.Get(0)
|
||||||
if runner, ok = runnerRet.TryTable(); !ok {
|
if runner, ok = runnerRet.TryTable(); !ok {
|
||||||
fmt.Fprintln(os.Stderr, "runner did not return a table")
|
fmt.Fprintln(os.Stderr, "runner did not return a table")
|
||||||
|
exitCode = 125
|
||||||
|
input = userInput
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if code, ok := runner.Get(rt.StringValue("exitCode")).TryInt(); ok {
|
if code, ok := runner.Get(rt.StringValue("exitCode")).TryInt(); ok {
|
||||||
|
|
|
@ -19,9 +19,11 @@ local function transformHTMLandMD(text)
|
||||||
:gsub('|(.-)|(.-)|', function(entry1, entry2)
|
:gsub('|(.-)|(.-)|', function(entry1, entry2)
|
||||||
return string.format('%s - %s', entry1, entry2)
|
return string.format('%s - %s', entry1, entry2)
|
||||||
end)
|
end)
|
||||||
:gsub('^\n\n', '\n')
|
:gsub('<hr>', '{separator}')
|
||||||
|
:gsub('<.->', '')
|
||||||
|
--:gsub('^\n\n', '\n')
|
||||||
:gsub('\n%s+\n', '\n\n')
|
:gsub('\n%s+\n', '\n\n')
|
||||||
:gsub(' \n', '\n\n')
|
--:gsub(' \n', '\n\n')
|
||||||
:gsub('{{< (%w+) `(.-)` >}}', function(shortcode, text)
|
:gsub('{{< (%w+) `(.-)` >}}', function(shortcode, text)
|
||||||
return docfuncs.renderInfoBlock(shortcode, text)
|
return docfuncs.renderInfoBlock(shortcode, text)
|
||||||
end)
|
end)
|
||||||
|
@ -34,8 +36,6 @@ local function transformHTMLandMD(text)
|
||||||
:gsub('`[^\n].-`', lunacolors.cyan)
|
:gsub('`[^\n].-`', lunacolors.cyan)
|
||||||
:gsub('#+ (.-\n)', function(heading) return lunacolors.blue(lunacolors.bold('→ ' .. heading)) end)
|
:gsub('#+ (.-\n)', function(heading) return lunacolors.blue(lunacolors.bold('→ ' .. heading)) end)
|
||||||
:gsub('%*%*(.-)%*%*', lunacolors.bold)
|
:gsub('%*%*(.-)%*%*', lunacolors.bold)
|
||||||
:gsub('<hr>', '{separator}')
|
|
||||||
:gsub('<.->', '')
|
|
||||||
end
|
end
|
||||||
|
|
||||||
commander.register('doc', function(args, sinks)
|
commander.register('doc', function(args, sinks)
|
||||||
|
@ -64,6 +64,10 @@ Available sections: ]] .. table.concat(modules, ', ')
|
||||||
local valsStr = docs:match '^%-%-%-\n.-\n%-%-%-'
|
local valsStr = docs:match '^%-%-%-\n.-\n%-%-%-'
|
||||||
if valsStr then
|
if valsStr then
|
||||||
docs = docs:sub(valsStr:len() + 2, #docs)
|
docs = docs:sub(valsStr:len() + 2, #docs)
|
||||||
|
local pre = docs:sub(1, 1)
|
||||||
|
if pre == '\n' then
|
||||||
|
docs = docs:sub(2)
|
||||||
|
end
|
||||||
|
|
||||||
-- parse vals
|
-- parse vals
|
||||||
local lines = string.split(valsStr, '\n')
|
local lines = string.split(valsStr, '\n')
|
||||||
|
|
|
@ -40,7 +40,7 @@ function dirs.peak(num)
|
||||||
return dirRecents(num)
|
return dirRecents(num)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Add `d` to the recent directories.
|
--- Add `d` to the recent directories list.
|
||||||
function dirs.push(d)
|
function dirs.push(d)
|
||||||
dirs.recentDirs[dirs.recentSize + 1] = nil
|
dirs.recentDirs[dirs.recentSize + 1] = nil
|
||||||
if dirs.recentDirs[#dirs.recentDirs - 1] ~= d then
|
if dirs.recentDirs[#dirs.recentDirs - 1] ~= d then
|
||||||
|
@ -51,19 +51,19 @@ function dirs.push(d)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Remove `num` amount of dirs from the recent directories.
|
--- Remove the specified amount of dirs from the recent directories list.
|
||||||
-- @param num number
|
-- @param num number
|
||||||
function dirs.pop(num)
|
function dirs.pop(num)
|
||||||
return dirRecents(num, true)
|
return dirRecents(num, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get entry from recent directories.
|
--- Get entry from recent directories list based on index.
|
||||||
-- @param idx number
|
-- @param idx number
|
||||||
function dirs.recent(idx)
|
function dirs.recent(idx)
|
||||||
return dirs.recentDirs[idx]
|
return dirs.recentDirs[idx]
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Sets the old directory.
|
--- Sets the old directory string.
|
||||||
-- @param d string
|
-- @param d string
|
||||||
function dirs.setOld(d)
|
function dirs.setOld(d)
|
||||||
ok, d = pcall(fs.abs, d)
|
ok, d = pcall(fs.abs, d)
|
||||||
|
|
Loading…
Reference in New Issue