mirror of
https://github.com/Hilbis/Hilbish
synced 2025-07-07 11:32:03 +00:00
Compare commits
No commits in common. "9ab13054f32669db49af0571a0af24dc8fdc65ef" and "fd045ca4a1461867a3276ec5d60857e04f19c3aa" have entirely different histories.
9ab13054f3
...
fd045ca4a1
File diff suppressed because it is too large
Load Diff
@ -110,7 +110,7 @@ menu:
|
|||||||
]]
|
]]
|
||||||
|
|
||||||
for iface, dps in pairs(pieces) do
|
for iface, dps in pairs(pieces) do
|
||||||
local mod = iface ~= 'nature' and iface:match '(%w+)' or 'nature'
|
local mod = iface:match '(%w+)%.' or 'nature'
|
||||||
local docParent = 'Nature'
|
local docParent = 'Nature'
|
||||||
|
|
||||||
path = string.format('docs/%s/%s.md', mod, iface)
|
path = string.format('docs/%s/%s.md', mod, iface)
|
||||||
@ -128,21 +128,100 @@ for iface, dps in pairs(pieces) do
|
|||||||
local exists = pcall(fs.stat, path)
|
local exists = pcall(fs.stat, path)
|
||||||
local newOrNotNature = (exists and mod ~= 'nature') or iface == 'hilbish'
|
local newOrNotNature = (exists and mod ~= 'nature') or iface == 'hilbish'
|
||||||
|
|
||||||
--local f <close> = io.open(path, newOrNotNature and 'r+' or 'w+')
|
local f <close> = io.open(path, newOrNotNature and 'r+' or 'w+')
|
||||||
|
local tocPos
|
||||||
if not newOrNotNature then
|
if not newOrNotNature then
|
||||||
--f:write(string.format(header, 'Module', iface, (descriptions[iface] and #descriptions[iface] > 0) and descriptions[iface][1] or 'No description.', docParent))
|
f:write(string.format(header, 'Module', iface, (descriptions[iface] and #descriptions[iface] > 0) and descriptions[iface][1] or 'No description.', docParent))
|
||||||
if descriptions[iface] and #descriptions[iface] > 0 then
|
if descriptions[iface] and #descriptions[iface] > 0 then
|
||||||
table.remove(descriptions[iface], 1)
|
table.remove(descriptions[iface], 1)
|
||||||
--f:write(string.format('\n## Introduction\n%s\n\n', table.concat(descriptions[iface], '\n')))
|
f:write(string.format('\n## Introduction\n%s\n\n', table.concat(descriptions[iface], '\n')))
|
||||||
--f:write('## Functions\n')
|
f:write('## Functions\n')
|
||||||
|
f:write([[|||
|
||||||
|
|----|----|
|
||||||
|
]])
|
||||||
|
tocPos = f:seek()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local tocSearch = false
|
||||||
|
for line in f:lines() do
|
||||||
|
if line:match '^## Functions' then
|
||||||
|
tocSearch = true
|
||||||
|
end
|
||||||
|
if tocSearch and line == '' then
|
||||||
|
tocSearch = false
|
||||||
|
tocPos = f:seek() - 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
print(mod, dps)
|
|
||||||
table.sort(dps, function(a, b) return a[1] < b[1] end)
|
table.sort(dps, function(a, b) return a[1] < b[1] end)
|
||||||
--[[for _, piece in pairs(dps) do
|
for _, piece in pairs(dps) do
|
||||||
local func = piece[1]
|
local func = piece[1]
|
||||||
local docs = piece[2]
|
local docs = piece[2]
|
||||||
print(func, docs)
|
local sig = string.format('%s.%s(', iface, func)
|
||||||
end]]
|
local params = ''
|
||||||
|
for idx, param in ipairs(docs.params) do
|
||||||
|
sig = sig .. param.name:gsub('%?$', '')
|
||||||
|
params = params .. param.name:gsub('%?$', '')
|
||||||
|
if idx ~= #docs.params then
|
||||||
|
sig = sig .. ', '
|
||||||
|
params = params .. ', '
|
||||||
|
end
|
||||||
|
end
|
||||||
|
sig = sig .. ')'
|
||||||
|
|
||||||
|
if tocPos then
|
||||||
|
f:seek('set', tocPos)
|
||||||
|
local contents = f:read '*a'
|
||||||
|
f:seek('set', tocPos)
|
||||||
|
local tocLine = string.format('|<a href="#%s">%s</a>|%s|\n', func, string.format('%s(%s)', func, params), docs.description[1])
|
||||||
|
f:write(tocLine .. contents)
|
||||||
|
f:seek 'end'
|
||||||
|
end
|
||||||
|
|
||||||
|
f:write(string.format('<hr>\n<div id=\'%s\'>\n', func))
|
||||||
|
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))
|
||||||
|
f:write(string.format('%s\n\n', param.description))
|
||||||
|
end
|
||||||
|
if #docs.example ~= 0 then
|
||||||
|
f:write '#### Example\n'
|
||||||
|
f:write(string.format('```lua\n%s\n```\n', table.concat(docs.example, '\n')))
|
||||||
|
end
|
||||||
|
--[[
|
||||||
|
local params = table.filter(docs, function(t)
|
||||||
|
return t:match '^%-%-%- @param'
|
||||||
|
end)
|
||||||
|
for i, str in ipairs(params) do
|
||||||
|
if i ~= 1 then
|
||||||
|
f:write ', '
|
||||||
|
end
|
||||||
|
f:write(str:match '^%-%-%- @param ([%w]+) ')
|
||||||
|
end
|
||||||
|
f:write(')\n')
|
||||||
|
|
||||||
|
for _, str in ipairs(docs) do
|
||||||
|
if not str:match '^%-%-%- @' then
|
||||||
|
f:write(str:match '^%-%-%- (.+)' .. '\n')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
]]--
|
||||||
|
f:write('</div>')
|
||||||
|
f:write('\n\n')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
388
defs/bait.json
388
defs/bait.json
@ -1,388 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "bait",
|
|
||||||
"shortDescription": "the event emitter",
|
|
||||||
"description": "\nBait is the event emitter for Hilbish. Much like Node.js and\nits `events` system, many actions in Hilbish emit events.\nUnlike Node.js, Hilbish events are global. So make sure to\npick a unique name!\n\nUsage of the Bait module consists of userstanding\nevent-driven architecture, but it's pretty simple:\nIf you want to act on a certain event, you can `catch` it.\nYou can act on events via callback functions.\n\nExamples of this are in the Hilbish default config!\nConsider this part of it:\n```lua\nbait.catch('command.exit', function(code)\n\trunning = false\n\tdoPrompt(code ~= 0)\n\tdoNotifyPrompt()\nend)\n```\n\nWhat this does is, whenever the `command.exit` event is thrown,\nthis function will set the user prompt.",
|
|
||||||
"properties": [],
|
|
||||||
"fields": [],
|
|
||||||
"docs": [
|
|
||||||
{
|
|
||||||
"name": "catch",
|
|
||||||
"description": [
|
|
||||||
"Catches an event. This function can be used to act on events.",
|
|
||||||
"",
|
|
||||||
""
|
|
||||||
],
|
|
||||||
"signature": "catch(name, cb)",
|
|
||||||
"goFuncName": "bcatch",
|
|
||||||
"isInterface": false,
|
|
||||||
"isMember": false,
|
|
||||||
"isType": false,
|
|
||||||
"params": [
|
|
||||||
{
|
|
||||||
"Name": "name",
|
|
||||||
"Type": "string",
|
|
||||||
"Doc": [
|
|
||||||
"The",
|
|
||||||
"name",
|
|
||||||
"of",
|
|
||||||
"the",
|
|
||||||
"hook."
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"Name": "cb",
|
|
||||||
"Type": "function",
|
|
||||||
"Doc": [
|
|
||||||
"The",
|
|
||||||
"function",
|
|
||||||
"that",
|
|
||||||
"will",
|
|
||||||
"be",
|
|
||||||
"called",
|
|
||||||
"when",
|
|
||||||
"the",
|
|
||||||
"hook",
|
|
||||||
"is",
|
|
||||||
"thrown."
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"tags": {
|
|
||||||
"example": [
|
|
||||||
{
|
|
||||||
"id": "",
|
|
||||||
"fields": [
|
|
||||||
"bait.catch('hilbish.exit', function()",
|
|
||||||
"\tprint 'Goodbye Hilbish!'",
|
|
||||||
"end)"
|
|
||||||
],
|
|
||||||
"StartIdx": 5
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"param": [
|
|
||||||
{
|
|
||||||
"id": "name",
|
|
||||||
"fields": [
|
|
||||||
"string",
|
|
||||||
"The",
|
|
||||||
"name",
|
|
||||||
"of",
|
|
||||||
"the",
|
|
||||||
"hook."
|
|
||||||
],
|
|
||||||
"StartIdx": 2
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "cb",
|
|
||||||
"fields": [
|
|
||||||
"function",
|
|
||||||
"The",
|
|
||||||
"function",
|
|
||||||
"that",
|
|
||||||
"will",
|
|
||||||
"be",
|
|
||||||
"called",
|
|
||||||
"when",
|
|
||||||
"the",
|
|
||||||
"hook",
|
|
||||||
"is",
|
|
||||||
"thrown."
|
|
||||||
],
|
|
||||||
"StartIdx": 0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "catchOnce",
|
|
||||||
"description": [
|
|
||||||
"Catches an event, but only once. This will remove the hook immediately after it runs for the first time."
|
|
||||||
],
|
|
||||||
"signature": "catchOnce(name, cb)",
|
|
||||||
"goFuncName": "bcatchonce",
|
|
||||||
"isInterface": false,
|
|
||||||
"isMember": false,
|
|
||||||
"isType": false,
|
|
||||||
"params": [
|
|
||||||
{
|
|
||||||
"Name": "name",
|
|
||||||
"Type": "string",
|
|
||||||
"Doc": [
|
|
||||||
"The",
|
|
||||||
"name",
|
|
||||||
"of",
|
|
||||||
"the",
|
|
||||||
"event"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"Name": "cb",
|
|
||||||
"Type": "function",
|
|
||||||
"Doc": [
|
|
||||||
"The",
|
|
||||||
"function",
|
|
||||||
"that",
|
|
||||||
"will",
|
|
||||||
"be",
|
|
||||||
"called",
|
|
||||||
"when",
|
|
||||||
"the",
|
|
||||||
"event",
|
|
||||||
"is",
|
|
||||||
"thrown."
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"tags": {
|
|
||||||
"param": [
|
|
||||||
{
|
|
||||||
"id": "name",
|
|
||||||
"fields": [
|
|
||||||
"string",
|
|
||||||
"The",
|
|
||||||
"name",
|
|
||||||
"of",
|
|
||||||
"the",
|
|
||||||
"event"
|
|
||||||
],
|
|
||||||
"StartIdx": 2
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "cb",
|
|
||||||
"fields": [
|
|
||||||
"function",
|
|
||||||
"The",
|
|
||||||
"function",
|
|
||||||
"that",
|
|
||||||
"will",
|
|
||||||
"be",
|
|
||||||
"called",
|
|
||||||
"when",
|
|
||||||
"the",
|
|
||||||
"event",
|
|
||||||
"is",
|
|
||||||
"thrown."
|
|
||||||
],
|
|
||||||
"StartIdx": 0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "hooks",
|
|
||||||
"description": [
|
|
||||||
"Returns a table of functions that are hooked on an event with the corresponding `name`."
|
|
||||||
],
|
|
||||||
"signature": "hooks(name) -\u003e table",
|
|
||||||
"goFuncName": "bhooks",
|
|
||||||
"isInterface": false,
|
|
||||||
"isMember": false,
|
|
||||||
"isType": false,
|
|
||||||
"params": [
|
|
||||||
{
|
|
||||||
"Name": "name",
|
|
||||||
"Type": "string",
|
|
||||||
"Doc": [
|
|
||||||
"The",
|
|
||||||
"name",
|
|
||||||
"of",
|
|
||||||
"the",
|
|
||||||
"hook"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"tags": {
|
|
||||||
"param": [
|
|
||||||
{
|
|
||||||
"id": "name",
|
|
||||||
"fields": [
|
|
||||||
"string",
|
|
||||||
"The",
|
|
||||||
"name",
|
|
||||||
"of",
|
|
||||||
"the",
|
|
||||||
"hook"
|
|
||||||
],
|
|
||||||
"StartIdx": 2
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"returns": [
|
|
||||||
{
|
|
||||||
"id": "table\u003cfunction\u003e",
|
|
||||||
"fields": [],
|
|
||||||
"StartIdx": 3
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "release",
|
|
||||||
"description": [
|
|
||||||
"Removes the `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.",
|
|
||||||
"",
|
|
||||||
""
|
|
||||||
],
|
|
||||||
"signature": "release(name, catcher)",
|
|
||||||
"goFuncName": "brelease",
|
|
||||||
"isInterface": false,
|
|
||||||
"isMember": false,
|
|
||||||
"isType": false,
|
|
||||||
"params": [
|
|
||||||
{
|
|
||||||
"Name": "name",
|
|
||||||
"Type": "string",
|
|
||||||
"Doc": [
|
|
||||||
"Name",
|
|
||||||
"of",
|
|
||||||
"the",
|
|
||||||
"event",
|
|
||||||
"the",
|
|
||||||
"hook",
|
|
||||||
"is",
|
|
||||||
"on"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"Name": "catcher",
|
|
||||||
"Type": "function",
|
|
||||||
"Doc": [
|
|
||||||
"Hook",
|
|
||||||
"function",
|
|
||||||
"to",
|
|
||||||
"remove"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"tags": {
|
|
||||||
"example": [
|
|
||||||
{
|
|
||||||
"id": "",
|
|
||||||
"fields": [
|
|
||||||
"local hookCallback = function() print 'hi' end",
|
|
||||||
"",
|
|
||||||
"bait.catch('event', hookCallback)",
|
|
||||||
"",
|
|
||||||
"-- a little while later....",
|
|
||||||
"bait.release('event', hookCallback)",
|
|
||||||
"-- and now hookCallback will no longer be ran for the event."
|
|
||||||
],
|
|
||||||
"StartIdx": 7
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"param": [
|
|
||||||
{
|
|
||||||
"id": "name",
|
|
||||||
"fields": [
|
|
||||||
"string",
|
|
||||||
"Name",
|
|
||||||
"of",
|
|
||||||
"the",
|
|
||||||
"event",
|
|
||||||
"the",
|
|
||||||
"hook",
|
|
||||||
"is",
|
|
||||||
"on"
|
|
||||||
],
|
|
||||||
"StartIdx": 4
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "catcher",
|
|
||||||
"fields": [
|
|
||||||
"function",
|
|
||||||
"Hook",
|
|
||||||
"function",
|
|
||||||
"to",
|
|
||||||
"remove"
|
|
||||||
],
|
|
||||||
"StartIdx": 0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "throw",
|
|
||||||
"description": [
|
|
||||||
"Throws a hook with `name` with the provided `args`.",
|
|
||||||
"",
|
|
||||||
""
|
|
||||||
],
|
|
||||||
"signature": "throw(name, ...args)",
|
|
||||||
"goFuncName": "bthrow",
|
|
||||||
"isInterface": false,
|
|
||||||
"isMember": false,
|
|
||||||
"isType": false,
|
|
||||||
"params": [
|
|
||||||
{
|
|
||||||
"Name": "name",
|
|
||||||
"Type": "string",
|
|
||||||
"Doc": [
|
|
||||||
"The",
|
|
||||||
"name",
|
|
||||||
"of",
|
|
||||||
"the",
|
|
||||||
"hook."
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"Name": "args",
|
|
||||||
"Type": "...any",
|
|
||||||
"Doc": [
|
|
||||||
"The",
|
|
||||||
"arguments",
|
|
||||||
"to",
|
|
||||||
"pass",
|
|
||||||
"to",
|
|
||||||
"the",
|
|
||||||
"hook."
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"tags": {
|
|
||||||
"example": [
|
|
||||||
{
|
|
||||||
"id": "",
|
|
||||||
"fields": [
|
|
||||||
"bait.throw('greeting', 'world')",
|
|
||||||
"",
|
|
||||||
"-- This can then be listened to via",
|
|
||||||
"bait.catch('gretting', function(greetTo)",
|
|
||||||
"\tprint('Hello ' .. greetTo)",
|
|
||||||
"end)"
|
|
||||||
],
|
|
||||||
"StartIdx": 5
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"param": [
|
|
||||||
{
|
|
||||||
"id": "name",
|
|
||||||
"fields": [
|
|
||||||
"string",
|
|
||||||
"The",
|
|
||||||
"name",
|
|
||||||
"of",
|
|
||||||
"the",
|
|
||||||
"hook."
|
|
||||||
],
|
|
||||||
"StartIdx": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "args",
|
|
||||||
"fields": [
|
|
||||||
"...any",
|
|
||||||
"The",
|
|
||||||
"arguments",
|
|
||||||
"to",
|
|
||||||
"pass",
|
|
||||||
"to",
|
|
||||||
"the",
|
|
||||||
"hook."
|
|
||||||
],
|
|
||||||
"StartIdx": 0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
@ -1,152 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "commander",
|
|
||||||
"shortDescription": "library for custom commands",
|
|
||||||
"description": "\nCommander is the library which handles Hilbish commands. This makes\nthe user able to add Lua-written commands to their shell without making\na separate script in a bin folder. Instead, you may simply use the Commander\nlibrary in your Hilbish config.\n\n```lua\nlocal commander = require 'commander'\n\ncommander.register('hello', function(args, sinks)\n\tsinks.out:writeln 'Hello world!'\nend)\n```\n\nIn this example, a command with the name of `hello` is created\nthat will print `Hello world!` to output. One question you may\nhave is: What is the `sinks` parameter?\n\nThe `sinks` parameter is a table with 3 keys: `input`, `out`, and `err`.\nThere is an `in` alias to `input`, but it requires using the string accessor syntax (`sinks['in']`)\nas `in` is also a Lua keyword, so `input` is preferred for use.\nAll of them are a @Sink.\nIn the future, `sinks.in` will be removed.\n\n- `in` is the standard input.\nYou may use the read functions on this sink to get input from the user.\n- `out` is standard output.\nThis is usually where command output should go.\n- `err` is standard error.\nThis sink is for writing errors, as the name would suggest.",
|
|
||||||
"properties": [],
|
|
||||||
"fields": [],
|
|
||||||
"docs": [
|
|
||||||
{
|
|
||||||
"name": "deregister",
|
|
||||||
"description": [
|
|
||||||
"Removes the named command. Note that this will only remove Commander-registered commands."
|
|
||||||
],
|
|
||||||
"signature": "deregister(name)",
|
|
||||||
"goFuncName": "cderegister",
|
|
||||||
"isInterface": false,
|
|
||||||
"isMember": false,
|
|
||||||
"isType": false,
|
|
||||||
"params": [
|
|
||||||
{
|
|
||||||
"Name": "name",
|
|
||||||
"Type": "string",
|
|
||||||
"Doc": [
|
|
||||||
"Name",
|
|
||||||
"of",
|
|
||||||
"the",
|
|
||||||
"command",
|
|
||||||
"to",
|
|
||||||
"remove."
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"tags": {
|
|
||||||
"param": [
|
|
||||||
{
|
|
||||||
"id": "name",
|
|
||||||
"fields": [
|
|
||||||
"string",
|
|
||||||
"Name",
|
|
||||||
"of",
|
|
||||||
"the",
|
|
||||||
"command",
|
|
||||||
"to",
|
|
||||||
"remove."
|
|
||||||
],
|
|
||||||
"StartIdx": 2
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "register",
|
|
||||||
"description": [
|
|
||||||
"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.",
|
|
||||||
"",
|
|
||||||
""
|
|
||||||
],
|
|
||||||
"signature": "register(name, cb)",
|
|
||||||
"goFuncName": "cregister",
|
|
||||||
"isInterface": false,
|
|
||||||
"isMember": false,
|
|
||||||
"isType": false,
|
|
||||||
"params": [
|
|
||||||
{
|
|
||||||
"Name": "name",
|
|
||||||
"Type": "string",
|
|
||||||
"Doc": [
|
|
||||||
"Name",
|
|
||||||
"of",
|
|
||||||
"the",
|
|
||||||
"command"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"Name": "cb",
|
|
||||||
"Type": "function",
|
|
||||||
"Doc": [
|
|
||||||
"Callback",
|
|
||||||
"to",
|
|
||||||
"handle",
|
|
||||||
"command",
|
|
||||||
"invocation"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"tags": {
|
|
||||||
"example": [
|
|
||||||
{
|
|
||||||
"id": "",
|
|
||||||
"fields": [
|
|
||||||
"-- 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)",
|
|
||||||
"\tlocal name = 'world'",
|
|
||||||
"\tif #args \u003e 0 then name = args[1] end",
|
|
||||||
"",
|
|
||||||
"\tsinks.out:writeln('Hello ' .. name)",
|
|
||||||
"end)"
|
|
||||||
],
|
|
||||||
"StartIdx": 6
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"param": [
|
|
||||||
{
|
|
||||||
"id": "name",
|
|
||||||
"fields": [
|
|
||||||
"string",
|
|
||||||
"Name",
|
|
||||||
"of",
|
|
||||||
"the",
|
|
||||||
"command"
|
|
||||||
],
|
|
||||||
"StartIdx": 3
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "cb",
|
|
||||||
"fields": [
|
|
||||||
"function",
|
|
||||||
"Callback",
|
|
||||||
"to",
|
|
||||||
"handle",
|
|
||||||
"command",
|
|
||||||
"invocation"
|
|
||||||
],
|
|
||||||
"StartIdx": 0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "registry",
|
|
||||||
"description": [
|
|
||||||
"Returns all registered commanders. Returns a list of tables with the following keys:",
|
|
||||||
"- `exec`: The function used to run the commander. Commanders require args and sinks to be passed."
|
|
||||||
],
|
|
||||||
"signature": "registry() -\u003e table",
|
|
||||||
"goFuncName": "cregistry",
|
|
||||||
"isInterface": false,
|
|
||||||
"isMember": false,
|
|
||||||
"isType": false,
|
|
||||||
"tags": {
|
|
||||||
"returns": [
|
|
||||||
{
|
|
||||||
"id": "table",
|
|
||||||
"fields": [],
|
|
||||||
"StartIdx": 3
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
549
defs/fs.json
549
defs/fs.json
@ -1,549 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "fs",
|
|
||||||
"shortDescription": "filesystem interaction and functionality library",
|
|
||||||
"description": "\nThe fs module provides filesystem functions to Hilbish. While Lua's standard\nlibrary has some I/O functions, they're missing a lot of the basics. The `fs`\nlibrary offers more functions and will work on any operating system Hilbish does.",
|
|
||||||
"properties": [],
|
|
||||||
"fields": [
|
|
||||||
{
|
|
||||||
"name": "pathSep",
|
|
||||||
"description": [
|
|
||||||
"The",
|
|
||||||
"operating",
|
|
||||||
"system's",
|
|
||||||
"path",
|
|
||||||
"separator."
|
|
||||||
],
|
|
||||||
"isInterface": false,
|
|
||||||
"isMember": false,
|
|
||||||
"isType": false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"docs": [
|
|
||||||
{
|
|
||||||
"name": "abs",
|
|
||||||
"description": [
|
|
||||||
"Returns an absolute version of the `path`.",
|
|
||||||
"This can be used to resolve short paths like `..` to `/home/user`."
|
|
||||||
],
|
|
||||||
"signature": "abs(path) -\u003e string",
|
|
||||||
"goFuncName": "fabs",
|
|
||||||
"isInterface": false,
|
|
||||||
"isMember": false,
|
|
||||||
"isType": false,
|
|
||||||
"params": [
|
|
||||||
{
|
|
||||||
"Name": "path",
|
|
||||||
"Type": "string",
|
|
||||||
"Doc": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"tags": {
|
|
||||||
"param": [
|
|
||||||
{
|
|
||||||
"id": "path",
|
|
||||||
"fields": [
|
|
||||||
"string"
|
|
||||||
],
|
|
||||||
"StartIdx": 3
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"returns": [
|
|
||||||
{
|
|
||||||
"id": "string",
|
|
||||||
"fields": [],
|
|
||||||
"StartIdx": 4
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "basename",
|
|
||||||
"description": [
|
|
||||||
"Returns the \"basename,\" or the last part of the provided `path`. If path is empty,",
|
|
||||||
"`.` will be returned."
|
|
||||||
],
|
|
||||||
"signature": "basename(path) -\u003e string",
|
|
||||||
"goFuncName": "fbasename",
|
|
||||||
"isInterface": false,
|
|
||||||
"isMember": false,
|
|
||||||
"isType": false,
|
|
||||||
"params": [
|
|
||||||
{
|
|
||||||
"Name": "path",
|
|
||||||
"Type": "string",
|
|
||||||
"Doc": [
|
|
||||||
"Path",
|
|
||||||
"to",
|
|
||||||
"get",
|
|
||||||
"the",
|
|
||||||
"base",
|
|
||||||
"name",
|
|
||||||
"of."
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"tags": {
|
|
||||||
"param": [
|
|
||||||
{
|
|
||||||
"id": "path",
|
|
||||||
"fields": [
|
|
||||||
"string",
|
|
||||||
"Path",
|
|
||||||
"to",
|
|
||||||
"get",
|
|
||||||
"the",
|
|
||||||
"base",
|
|
||||||
"name",
|
|
||||||
"of."
|
|
||||||
],
|
|
||||||
"StartIdx": 3
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"returns": [
|
|
||||||
{
|
|
||||||
"id": "string",
|
|
||||||
"fields": [],
|
|
||||||
"StartIdx": 4
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cd",
|
|
||||||
"description": [
|
|
||||||
"Changes Hilbish's directory to `dir`."
|
|
||||||
],
|
|
||||||
"signature": "cd(dir)",
|
|
||||||
"goFuncName": "fcd",
|
|
||||||
"isInterface": false,
|
|
||||||
"isMember": false,
|
|
||||||
"isType": false,
|
|
||||||
"params": [
|
|
||||||
{
|
|
||||||
"Name": "dir",
|
|
||||||
"Type": "string",
|
|
||||||
"Doc": [
|
|
||||||
"Path",
|
|
||||||
"to",
|
|
||||||
"change",
|
|
||||||
"directory",
|
|
||||||
"to."
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"tags": {
|
|
||||||
"param": [
|
|
||||||
{
|
|
||||||
"id": "dir",
|
|
||||||
"fields": [
|
|
||||||
"string",
|
|
||||||
"Path",
|
|
||||||
"to",
|
|
||||||
"change",
|
|
||||||
"directory",
|
|
||||||
"to."
|
|
||||||
],
|
|
||||||
"StartIdx": 2
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "dir",
|
|
||||||
"description": [
|
|
||||||
"Returns the directory part of `path`. If a file path like",
|
|
||||||
"`~/Documents/doc.txt` then this function will return `~/Documents`."
|
|
||||||
],
|
|
||||||
"signature": "dir(path) -\u003e string",
|
|
||||||
"goFuncName": "fdir",
|
|
||||||
"isInterface": false,
|
|
||||||
"isMember": false,
|
|
||||||
"isType": false,
|
|
||||||
"params": [
|
|
||||||
{
|
|
||||||
"Name": "path",
|
|
||||||
"Type": "string",
|
|
||||||
"Doc": [
|
|
||||||
"Path",
|
|
||||||
"to",
|
|
||||||
"get",
|
|
||||||
"the",
|
|
||||||
"directory",
|
|
||||||
"for."
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"tags": {
|
|
||||||
"param": [
|
|
||||||
{
|
|
||||||
"id": "path",
|
|
||||||
"fields": [
|
|
||||||
"string",
|
|
||||||
"Path",
|
|
||||||
"to",
|
|
||||||
"get",
|
|
||||||
"the",
|
|
||||||
"directory",
|
|
||||||
"for."
|
|
||||||
],
|
|
||||||
"StartIdx": 3
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"returns": [
|
|
||||||
{
|
|
||||||
"id": "string",
|
|
||||||
"fields": [],
|
|
||||||
"StartIdx": 4
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "glob",
|
|
||||||
"description": [
|
|
||||||
"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",
|
|
||||||
"",
|
|
||||||
""
|
|
||||||
],
|
|
||||||
"signature": "glob(pattern) -\u003e matches (table)",
|
|
||||||
"goFuncName": "fglob",
|
|
||||||
"isInterface": false,
|
|
||||||
"isMember": false,
|
|
||||||
"isType": false,
|
|
||||||
"params": [
|
|
||||||
{
|
|
||||||
"Name": "pattern",
|
|
||||||
"Type": "string",
|
|
||||||
"Doc": [
|
|
||||||
"Pattern",
|
|
||||||
"to",
|
|
||||||
"compare",
|
|
||||||
"files",
|
|
||||||
"with."
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"tags": {
|
|
||||||
"example": [
|
|
||||||
{
|
|
||||||
"id": "",
|
|
||||||
"fields": [
|
|
||||||
"--[[",
|
|
||||||
"\tWithin a folder that contains the following files:",
|
|
||||||
"\ta.txt",
|
|
||||||
"\tinit.lua",
|
|
||||||
"\tcode.lua",
|
|
||||||
"\tdoc.pdf",
|
|
||||||
"]]--",
|
|
||||||
"local matches = fs.glob './*.lua'",
|
|
||||||
"print(matches)",
|
|
||||||
"-- -\u003e {'init.lua', 'code.lua'}"
|
|
||||||
],
|
|
||||||
"StartIdx": 6
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"param": [
|
|
||||||
{
|
|
||||||
"id": "pattern",
|
|
||||||
"fields": [
|
|
||||||
"string",
|
|
||||||
"Pattern",
|
|
||||||
"to",
|
|
||||||
"compare",
|
|
||||||
"files",
|
|
||||||
"with."
|
|
||||||
],
|
|
||||||
"StartIdx": 3
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"returns": [
|
|
||||||
{
|
|
||||||
"id": "table",
|
|
||||||
"fields": [
|
|
||||||
"A",
|
|
||||||
"list",
|
|
||||||
"of",
|
|
||||||
"file",
|
|
||||||
"names/paths",
|
|
||||||
"that",
|
|
||||||
"match."
|
|
||||||
],
|
|
||||||
"StartIdx": 4
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "join",
|
|
||||||
"description": [
|
|
||||||
"Takes any list of paths and joins them based on the operating system's path separator.",
|
|
||||||
"",
|
|
||||||
""
|
|
||||||
],
|
|
||||||
"signature": "join(...path) -\u003e string",
|
|
||||||
"goFuncName": "fjoin",
|
|
||||||
"isInterface": false,
|
|
||||||
"isMember": false,
|
|
||||||
"isType": false,
|
|
||||||
"params": [
|
|
||||||
{
|
|
||||||
"Name": "path",
|
|
||||||
"Type": "...string",
|
|
||||||
"Doc": [
|
|
||||||
"Paths",
|
|
||||||
"to",
|
|
||||||
"join",
|
|
||||||
"together"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"tags": {
|
|
||||||
"example": [
|
|
||||||
{
|
|
||||||
"id": "",
|
|
||||||
"fields": [
|
|
||||||
"-- This prints the directory for Hilbish's config!",
|
|
||||||
"print(fs.join(hilbish.userDir.config, 'hilbish'))",
|
|
||||||
"-- -\u003e '/home/user/.config/hilbish' on Linux"
|
|
||||||
],
|
|
||||||
"StartIdx": 5
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"param": [
|
|
||||||
{
|
|
||||||
"id": "path",
|
|
||||||
"fields": [
|
|
||||||
"...string",
|
|
||||||
"Paths",
|
|
||||||
"to",
|
|
||||||
"join",
|
|
||||||
"together"
|
|
||||||
],
|
|
||||||
"StartIdx": 2
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"returns": [
|
|
||||||
{
|
|
||||||
"id": "string",
|
|
||||||
"fields": [
|
|
||||||
"The",
|
|
||||||
"joined",
|
|
||||||
"path."
|
|
||||||
],
|
|
||||||
"StartIdx": 3
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "mkdir",
|
|
||||||
"description": [
|
|
||||||
"Creates a new directory with the provided `name`.",
|
|
||||||
"With `recursive`, mkdir will create parent directories.",
|
|
||||||
"",
|
|
||||||
""
|
|
||||||
],
|
|
||||||
"signature": "mkdir(name, recursive)",
|
|
||||||
"goFuncName": "fmkdir",
|
|
||||||
"isInterface": false,
|
|
||||||
"isMember": false,
|
|
||||||
"isType": false,
|
|
||||||
"params": [
|
|
||||||
{
|
|
||||||
"Name": "name",
|
|
||||||
"Type": "string",
|
|
||||||
"Doc": [
|
|
||||||
"Name",
|
|
||||||
"of",
|
|
||||||
"the",
|
|
||||||
"directory"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"Name": "recursive",
|
|
||||||
"Type": "boolean",
|
|
||||||
"Doc": [
|
|
||||||
"Whether",
|
|
||||||
"to",
|
|
||||||
"create",
|
|
||||||
"parent",
|
|
||||||
"directories",
|
|
||||||
"for",
|
|
||||||
"the",
|
|
||||||
"provided",
|
|
||||||
"name"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"tags": {
|
|
||||||
"example": [
|
|
||||||
{
|
|
||||||
"id": "",
|
|
||||||
"fields": [
|
|
||||||
"-- 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)"
|
|
||||||
],
|
|
||||||
"StartIdx": 6
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"param": [
|
|
||||||
{
|
|
||||||
"id": "name",
|
|
||||||
"fields": [
|
|
||||||
"string",
|
|
||||||
"Name",
|
|
||||||
"of",
|
|
||||||
"the",
|
|
||||||
"directory"
|
|
||||||
],
|
|
||||||
"StartIdx": 3
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "recursive",
|
|
||||||
"fields": [
|
|
||||||
"boolean",
|
|
||||||
"Whether",
|
|
||||||
"to",
|
|
||||||
"create",
|
|
||||||
"parent",
|
|
||||||
"directories",
|
|
||||||
"for",
|
|
||||||
"the",
|
|
||||||
"provided",
|
|
||||||
"name"
|
|
||||||
],
|
|
||||||
"StartIdx": 0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "pipe",
|
|
||||||
"description": [
|
|
||||||
"Returns a pair of connected files, also known as a pipe.",
|
|
||||||
"The type returned is a Lua file, same as returned from `io` functions."
|
|
||||||
],
|
|
||||||
"signature": "fpipe() -\u003e File, File",
|
|
||||||
"goFuncName": "fpipe",
|
|
||||||
"isInterface": false,
|
|
||||||
"isMember": false,
|
|
||||||
"isType": false,
|
|
||||||
"tags": {
|
|
||||||
"returns": [
|
|
||||||
{
|
|
||||||
"id": "File",
|
|
||||||
"fields": [],
|
|
||||||
"StartIdx": 3
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "File",
|
|
||||||
"fields": [],
|
|
||||||
"StartIdx": 0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "readdir",
|
|
||||||
"description": [
|
|
||||||
"Returns a list of all files and directories in the provided path."
|
|
||||||
],
|
|
||||||
"signature": "readdir(path) -\u003e table[string]",
|
|
||||||
"goFuncName": "freaddir",
|
|
||||||
"isInterface": false,
|
|
||||||
"isMember": false,
|
|
||||||
"isType": false,
|
|
||||||
"params": [
|
|
||||||
{
|
|
||||||
"Name": "dir",
|
|
||||||
"Type": "string",
|
|
||||||
"Doc": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"tags": {
|
|
||||||
"param": [
|
|
||||||
{
|
|
||||||
"id": "dir",
|
|
||||||
"fields": [
|
|
||||||
"string"
|
|
||||||
],
|
|
||||||
"StartIdx": 2
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"returns": [
|
|
||||||
{
|
|
||||||
"id": "table",
|
|
||||||
"fields": [],
|
|
||||||
"StartIdx": 3
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "stat",
|
|
||||||
"description": [
|
|
||||||
"Returns the information about a given `path`.",
|
|
||||||
"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",
|
|
||||||
"",
|
|
||||||
""
|
|
||||||
],
|
|
||||||
"signature": "stat(path) -\u003e {}",
|
|
||||||
"goFuncName": "fstat",
|
|
||||||
"isInterface": false,
|
|
||||||
"isMember": false,
|
|
||||||
"isType": false,
|
|
||||||
"params": [
|
|
||||||
{
|
|
||||||
"Name": "path",
|
|
||||||
"Type": "string",
|
|
||||||
"Doc": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"tags": {
|
|
||||||
"example": [
|
|
||||||
{
|
|
||||||
"id": "",
|
|
||||||
"fields": [
|
|
||||||
"local inspect = require 'inspect'",
|
|
||||||
"",
|
|
||||||
"local stat = fs.stat '~'",
|
|
||||||
"print(inspect(stat))",
|
|
||||||
"--[[",
|
|
||||||
"Would print the following:",
|
|
||||||
"{",
|
|
||||||
" isDir = true,",
|
|
||||||
" mode = \"0755\",",
|
|
||||||
" name = \"username\",",
|
|
||||||
" size = 12288",
|
|
||||||
"}",
|
|
||||||
"]]--"
|
|
||||||
],
|
|
||||||
"StartIdx": 10
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"param": [
|
|
||||||
{
|
|
||||||
"id": "path",
|
|
||||||
"fields": [
|
|
||||||
"string"
|
|
||||||
],
|
|
||||||
"StartIdx": 7
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"returns": [
|
|
||||||
{
|
|
||||||
"id": "table",
|
|
||||||
"fields": [],
|
|
||||||
"StartIdx": 8
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
3267
defs/hilbish.json
3267
defs/hilbish.json
File diff suppressed because it is too large
Load Diff
140
defs/snail.json
140
defs/snail.json
@ -1,140 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "snail",
|
|
||||||
"shortDescription": "shell script interpreter library",
|
|
||||||
"description": "\nThe snail library houses Hilbish's Lua wrapper of its shell script interpreter.\nIt's not very useful other than running shell scripts, which can be done with other\nHilbish functions.",
|
|
||||||
"properties": [],
|
|
||||||
"fields": [],
|
|
||||||
"types": [
|
|
||||||
{
|
|
||||||
"name": "Snail",
|
|
||||||
"description": [
|
|
||||||
"A Snail is a shell script interpreter instance."
|
|
||||||
],
|
|
||||||
"parent": "snail",
|
|
||||||
"isInterface": false,
|
|
||||||
"isMember": false,
|
|
||||||
"isType": true,
|
|
||||||
"tags": {
|
|
||||||
"type": [
|
|
||||||
{
|
|
||||||
"id": "",
|
|
||||||
"fields": null,
|
|
||||||
"StartIdx": 0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"docs": [
|
|
||||||
{
|
|
||||||
"name": "dir",
|
|
||||||
"description": [
|
|
||||||
"Changes the directory of the snail instance.",
|
|
||||||
"The interpreter keeps its set directory even when the Hilbish process changes",
|
|
||||||
"directory, so this should be called on the `hilbish.cd` hook."
|
|
||||||
],
|
|
||||||
"signature": "dir(path)",
|
|
||||||
"goFuncName": "snaildir",
|
|
||||||
"isInterface": false,
|
|
||||||
"isMember": true,
|
|
||||||
"isType": false,
|
|
||||||
"params": [
|
|
||||||
{
|
|
||||||
"Name": "path",
|
|
||||||
"Type": "string",
|
|
||||||
"Doc": [
|
|
||||||
"Has",
|
|
||||||
"to",
|
|
||||||
"be",
|
|
||||||
"an",
|
|
||||||
"absolute",
|
|
||||||
"path."
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"tags": {
|
|
||||||
"member": [
|
|
||||||
{
|
|
||||||
"id": "",
|
|
||||||
"fields": null,
|
|
||||||
"StartIdx": 0
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"param": [
|
|
||||||
{
|
|
||||||
"id": "path",
|
|
||||||
"fields": [
|
|
||||||
"string",
|
|
||||||
"Has",
|
|
||||||
"to",
|
|
||||||
"be",
|
|
||||||
"an",
|
|
||||||
"absolute",
|
|
||||||
"path."
|
|
||||||
],
|
|
||||||
"StartIdx": 5
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "new",
|
|
||||||
"description": [
|
|
||||||
"Creates a new Snail instance."
|
|
||||||
],
|
|
||||||
"signature": "new() -\u003e @Snail",
|
|
||||||
"goFuncName": "snailnew",
|
|
||||||
"isInterface": false,
|
|
||||||
"isMember": false,
|
|
||||||
"isType": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "run",
|
|
||||||
"description": [
|
|
||||||
"Runs a shell command. Works the same as `hilbish.run`, but only accepts a table of streams."
|
|
||||||
],
|
|
||||||
"signature": "run(command, streams)",
|
|
||||||
"goFuncName": "snailrun",
|
|
||||||
"isInterface": false,
|
|
||||||
"isMember": true,
|
|
||||||
"isType": false,
|
|
||||||
"params": [
|
|
||||||
{
|
|
||||||
"Name": "command",
|
|
||||||
"Type": "string",
|
|
||||||
"Doc": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"Name": "streams",
|
|
||||||
"Type": "table",
|
|
||||||
"Doc": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"tags": {
|
|
||||||
"member": [
|
|
||||||
{
|
|
||||||
"id": "",
|
|
||||||
"fields": null,
|
|
||||||
"StartIdx": 0
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"param": [
|
|
||||||
{
|
|
||||||
"id": "command",
|
|
||||||
"fields": [
|
|
||||||
"string"
|
|
||||||
],
|
|
||||||
"StartIdx": 3
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "streams",
|
|
||||||
"fields": [
|
|
||||||
"table"
|
|
||||||
],
|
|
||||||
"StartIdx": 0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
@ -1,54 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "terminal",
|
|
||||||
"shortDescription": "low level terminal library",
|
|
||||||
"description": "The terminal library is a simple and lower level library for certain terminal interactions.",
|
|
||||||
"properties": [],
|
|
||||||
"fields": [],
|
|
||||||
"docs": [
|
|
||||||
{
|
|
||||||
"name": "restoreState",
|
|
||||||
"description": [
|
|
||||||
"Restores the last saved state of the terminal"
|
|
||||||
],
|
|
||||||
"signature": "restoreState()",
|
|
||||||
"goFuncName": "termrestorestate",
|
|
||||||
"isInterface": false,
|
|
||||||
"isMember": false,
|
|
||||||
"isType": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "saveState",
|
|
||||||
"description": [
|
|
||||||
"Saves the current state of the terminal."
|
|
||||||
],
|
|
||||||
"signature": "saveState()",
|
|
||||||
"goFuncName": "termsavestate",
|
|
||||||
"isInterface": false,
|
|
||||||
"isMember": false,
|
|
||||||
"isType": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "setRaw",
|
|
||||||
"description": [
|
|
||||||
"Puts the terminal into raw mode."
|
|
||||||
],
|
|
||||||
"signature": "setRaw()",
|
|
||||||
"goFuncName": "termsetraw",
|
|
||||||
"isInterface": false,
|
|
||||||
"isMember": false,
|
|
||||||
"isType": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "size",
|
|
||||||
"description": [
|
|
||||||
"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."
|
|
||||||
],
|
|
||||||
"signature": "size()",
|
|
||||||
"goFuncName": "termsize",
|
|
||||||
"isInterface": false,
|
|
||||||
"isMember": false,
|
|
||||||
"isType": false
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
110
docs/api/bait.md
110
docs/api/bait.md
@ -9,7 +9,6 @@ menu:
|
|||||||
|
|
||||||
## Introduction
|
## Introduction
|
||||||
|
|
||||||
|
|
||||||
Bait is the event emitter for Hilbish. Much like Node.js and
|
Bait is the event emitter for Hilbish. Much like Node.js and
|
||||||
its `events` system, many actions in Hilbish emit events.
|
its `events` system, many actions in Hilbish emit events.
|
||||||
Unlike Node.js, Hilbish events are global. So make sure to
|
Unlike Node.js, Hilbish events are global. So make sure to
|
||||||
@ -34,140 +33,98 @@ What this does is, whenever the `command.exit` event is thrown,
|
|||||||
this function will set the user prompt.
|
this function will set the user prompt.
|
||||||
|
|
||||||
## Functions
|
## Functions
|
||||||
|
|||
|
||||||
|
|----|----|
|
||||||
|
|<a href="#catch">catch(name, cb)</a>|Catches an event. This function can be used to act on events.|
|
||||||
|
|<a href="#catchOnce">catchOnce(name, cb)</a>|Catches an event, but only once. This will remove the hook immediately after it runs for the first time.|
|
||||||
|
|<a href="#hooks">hooks(name) -> table</a>|Returns a table of functions that are hooked on an event with the corresponding `name`.|
|
||||||
|
|<a href="#release">release(name, catcher)</a>|Removes the `catcher` for the event with `name`.|
|
||||||
|
|<a href="#throw">throw(name, ...args)</a>|Throws a hook with `name` with the provided `args`.|
|
||||||
|
|
||||||
``` =html
|
<hr>
|
||||||
<div class='relative overflow-x-auto sm:rounded-lg my-4'>
|
|
||||||
<table class='w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400'>
|
|
||||||
<tbody>
|
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'><a href="#catch">catch(name, cb)</a></td>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Catches an event. This function can be used to act on events.</td>
|
|
||||||
</tr>
|
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'><a href="#catchOnce">catchOnce(name, cb)</a></td>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Catches an event, but only once. This will remove the hook immediately after it runs for the first time.</td>
|
|
||||||
</tr>
|
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'><a href="#hooks">hooks(name) -> table</a></td>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Returns a table of functions that are hooked on an event with the corresponding `name`.</td>
|
|
||||||
</tr>
|
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'><a href="#release">release(name, catcher)</a></td>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Removes the `catcher` for the event with `name`.</td>
|
|
||||||
</tr>
|
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'><a href="#throw">throw(name, ...args)</a></td>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Throws a hook with `name` with the provided `args`.</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
```
|
|
||||||
|
|
||||||
## Functions
|
|
||||||
|
|
||||||
``` =html
|
|
||||||
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
|
|
||||||
<div id='catch'>
|
<div id='catch'>
|
||||||
<h4 class='text-xl font-medium mb-2'>
|
<h4 class='heading'>
|
||||||
bait.catch(name, cb)
|
bait.catch(name, cb)
|
||||||
<a href="#catch" class='heading-link'>
|
<a href="#catch" class='heading-link'>
|
||||||
<i class="fas fa-paperclip"></i>
|
<i class="fas fa-paperclip"></i>
|
||||||
</a>
|
</a>
|
||||||
</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.
|
||||||
|
|
||||||
`function` `*cb*`
|
`function` **`cb`**
|
||||||
The function that will be called when the hook is thrown.
|
The function that will be called when the hook is thrown.
|
||||||
|
|
||||||
#### Example
|
#### Example
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
bait.catch('hilbish.exit', function()
|
bait.catch('hilbish.exit', function()
|
||||||
print 'Goodbye Hilbish!'
|
print 'Goodbye Hilbish!'
|
||||||
end)
|
end)
|
||||||
```
|
```
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
``` =html
|
|
||||||
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
|
|
||||||
<div id='catchOnce'>
|
<div id='catchOnce'>
|
||||||
<h4 class='text-xl font-medium mb-2'>
|
<h4 class='heading'>
|
||||||
bait.catchOnce(name, cb)
|
bait.catchOnce(name, cb)
|
||||||
<a href="#catchOnce" class='heading-link'>
|
<a href="#catchOnce" class='heading-link'>
|
||||||
<i class="fas fa-paperclip"></i>
|
<i class="fas fa-paperclip"></i>
|
||||||
</a>
|
</a>
|
||||||
</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
|
||||||
|
|
||||||
`function` `*cb*`
|
`function` **`cb`**
|
||||||
The function that will be called when the event is thrown.
|
The function that will be called when the event is thrown.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
``` =html
|
|
||||||
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
|
|
||||||
<div id='hooks'>
|
<div id='hooks'>
|
||||||
<h4 class='text-xl font-medium mb-2'>
|
<h4 class='heading'>
|
||||||
bait.hooks(name) -> table
|
bait.hooks(name) -> table
|
||||||
<a href="#hooks" class='heading-link'>
|
<a href="#hooks" class='heading-link'>
|
||||||
<i class="fas fa-paperclip"></i>
|
<i class="fas fa-paperclip"></i>
|
||||||
</a>
|
</a>
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
Returns a table of functions that are hooked on an event with the corresponding `name`.
|
Returns a table of functions that are hooked on an event with the corresponding `name`.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
`string` **`name`**
|
||||||
`string` `*name*`
|
|
||||||
The name of the hook
|
The name of the hook
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
``` =html
|
|
||||||
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
|
|
||||||
<div id='release'>
|
<div id='release'>
|
||||||
<h4 class='text-xl font-medium mb-2'>
|
<h4 class='heading'>
|
||||||
bait.release(name, catcher)
|
bait.release(name, catcher)
|
||||||
<a href="#release" class='heading-link'>
|
<a href="#release" class='heading-link'>
|
||||||
<i class="fas fa-paperclip"></i>
|
<i class="fas fa-paperclip"></i>
|
||||||
</a>
|
</a>
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
`function` `*catcher*`
|
`function` **`catcher`**
|
||||||
Hook function to remove
|
Hook function to remove
|
||||||
|
|
||||||
#### Example
|
#### Example
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local hookCallback = function() print 'hi' end
|
local hookCallback = function() print 'hi' end
|
||||||
|
|
||||||
@ -177,32 +134,27 @@ bait.catch('event', hookCallback)
|
|||||||
bait.release('event', hookCallback)
|
bait.release('event', hookCallback)
|
||||||
-- and now hookCallback will no longer be ran for the event.
|
-- and now hookCallback will no longer be ran for the event.
|
||||||
```
|
```
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
``` =html
|
|
||||||
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
|
|
||||||
<div id='throw'>
|
<div id='throw'>
|
||||||
<h4 class='text-xl font-medium mb-2'>
|
<h4 class='heading'>
|
||||||
bait.throw(name, ...args)
|
bait.throw(name, ...args)
|
||||||
<a href="#throw" class='heading-link'>
|
<a href="#throw" class='heading-link'>
|
||||||
<i class="fas fa-paperclip"></i>
|
<i class="fas fa-paperclip"></i>
|
||||||
</a>
|
</a>
|
||||||
</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.
|
||||||
|
|
||||||
`any` `*args*` (This type is variadic. You can pass an infinite amount of parameters with this type.)
|
`any` **`args`** (This type is variadic. You can pass an infinite amount of parameters with this type.)
|
||||||
The arguments to pass to the hook.
|
The arguments to pass to the hook.
|
||||||
|
|
||||||
#### Example
|
#### Example
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
bait.throw('greeting', 'world')
|
bait.throw('greeting', 'world')
|
||||||
|
|
||||||
@ -211,5 +163,5 @@ bait.catch('gretting', function(greetTo)
|
|||||||
print('Hello ' .. greetTo)
|
print('Hello ' .. greetTo)
|
||||||
end)
|
end)
|
||||||
```
|
```
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@ -9,7 +9,6 @@ menu:
|
|||||||
|
|
||||||
## Introduction
|
## Introduction
|
||||||
|
|
||||||
|
|
||||||
Commander is the library which handles Hilbish commands. This makes
|
Commander is the library which handles Hilbish commands. This makes
|
||||||
the user able to add Lua-written commands to their shell without making
|
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
|
a separate script in a bin folder. Instead, you may simply use the Commander
|
||||||
@ -30,7 +29,7 @@ have is: What is the `sinks` parameter?
|
|||||||
The `sinks` parameter is a table with 3 keys: `input`, `out`, and `err`.
|
The `sinks` parameter is a table with 3 keys: `input`, `out`, and `err`.
|
||||||
There is an `in` alias to `input`, but it requires using the string accessor syntax (`sinks['in']`)
|
There is an `in` alias to `input`, but it requires using the string accessor syntax (`sinks['in']`)
|
||||||
as `in` is also a Lua keyword, so `input` is preferred for use.
|
as `in` is also a Lua keyword, so `input` is preferred for use.
|
||||||
All of them are a @Sink.
|
All of them are a <a href="/Hilbish/docs/api/hilbish/#sink" style="text-decoration: none;">Sink</a>.
|
||||||
In the future, `sinks.in` will be removed.
|
In the future, `sinks.in` will be removed.
|
||||||
|
|
||||||
- `in` is the standard input.
|
- `in` is the standard input.
|
||||||
@ -41,76 +40,49 @@ This is usually where command output should go.
|
|||||||
This sink is for writing errors, as the name would suggest.
|
This sink is for writing errors, as the name would suggest.
|
||||||
|
|
||||||
## Functions
|
## Functions
|
||||||
|
|||
|
||||||
|
|----|----|
|
||||||
|
|<a href="#deregister">deregister(name)</a>|Removes the named command. Note that this will only remove Commander-registered commands.|
|
||||||
|
|<a href="#register">register(name, cb)</a>|Adds a new command with the given `name`. When Hilbish has to run a command with a name,|
|
||||||
|
|<a href="#registry">registry() -> table</a>|Returns all registered commanders. Returns a list of tables with the following keys:|
|
||||||
|
|
||||||
``` =html
|
<hr>
|
||||||
<div class='relative overflow-x-auto sm:rounded-lg my-4'>
|
|
||||||
<table class='w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400'>
|
|
||||||
<tbody>
|
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'><a href="#deregister">deregister(name)</a></td>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Removes the named command. Note that this will only remove Commander-registered commands.</td>
|
|
||||||
</tr>
|
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'><a href="#register">register(name, cb)</a></td>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Adds a new command with the given `name`. When Hilbish has to run a command with a name,</td>
|
|
||||||
</tr>
|
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'><a href="#registry">registry() -> table</a></td>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Returns all registered commanders. Returns a list of tables with the following keys:</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
```
|
|
||||||
|
|
||||||
## Functions
|
|
||||||
|
|
||||||
``` =html
|
|
||||||
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
|
|
||||||
<div id='deregister'>
|
<div id='deregister'>
|
||||||
<h4 class='text-xl font-medium mb-2'>
|
<h4 class='heading'>
|
||||||
commander.deregister(name)
|
commander.deregister(name)
|
||||||
<a href="#deregister" class='heading-link'>
|
<a href="#deregister" class='heading-link'>
|
||||||
<i class="fas fa-paperclip"></i>
|
<i class="fas fa-paperclip"></i>
|
||||||
</a>
|
</a>
|
||||||
</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.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
``` =html
|
|
||||||
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
|
|
||||||
<div id='register'>
|
<div id='register'>
|
||||||
<h4 class='text-xl font-medium mb-2'>
|
<h4 class='heading'>
|
||||||
commander.register(name, cb)
|
commander.register(name, cb)
|
||||||
<a href="#register" class='heading-link'>
|
<a href="#register" class='heading-link'>
|
||||||
<i class="fas fa-paperclip"></i>
|
<i class="fas fa-paperclip"></i>
|
||||||
</a>
|
</a>
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
`function` `*cb*`
|
`function` **`cb`**
|
||||||
Callback to handle command invocation
|
Callback to handle command invocation
|
||||||
|
|
||||||
#### Example
|
#### Example
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- When you run the command `hello` in the shell, it will print `Hello world`.
|
-- 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'
|
-- If you run it with, for example, `hello Hilbish`, it will print 'Hello Hilbish'
|
||||||
@ -121,25 +93,21 @@ commander.register('hello', function(args, sinks)
|
|||||||
sinks.out:writeln('Hello ' .. name)
|
sinks.out:writeln('Hello ' .. name)
|
||||||
end)
|
end)
|
||||||
```
|
```
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
``` =html
|
|
||||||
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
|
|
||||||
<div id='registry'>
|
<div id='registry'>
|
||||||
<h4 class='text-xl font-medium mb-2'>
|
<h4 class='heading'>
|
||||||
commander.registry() -> table
|
commander.registry() -> table
|
||||||
<a href="#registry" class='heading-link'>
|
<a href="#registry" class='heading-link'>
|
||||||
<i class="fas fa-paperclip"></i>
|
<i class="fas fa-paperclip"></i>
|
||||||
</a>
|
</a>
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
Returns all registered commanders. Returns a list of tables with the following keys:
|
Returns all registered commanders. Returns a list of tables with the following keys:
|
||||||
- `exec`: The function used to run the commander. Commanders require args and sinks to be passed.
|
- `exec`: The function used to run the commander. Commanders require args and sinks to be passed.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
204
docs/api/fs.md
204
docs/api/fs.md
@ -9,188 +9,117 @@ menu:
|
|||||||
|
|
||||||
## Introduction
|
## Introduction
|
||||||
|
|
||||||
|
|
||||||
The fs module provides filesystem functions to Hilbish. While Lua's standard
|
The fs module provides filesystem functions to Hilbish. While Lua's standard
|
||||||
library has some I/O functions, they're missing a lot of the basics. The `fs`
|
library has some I/O functions, they're missing a lot of the basics. The `fs`
|
||||||
library offers more functions and will work on any operating system Hilbish does.
|
library offers more functions and will work on any operating system Hilbish does.
|
||||||
|
|
||||||
## Functions
|
## Functions
|
||||||
|
|||
|
||||||
``` =html
|
|----|----|
|
||||||
<div class='relative overflow-x-auto sm:rounded-lg my-4'>
|
|<a href="#abs">abs(path) -> string</a>|Returns an absolute version of the `path`.|
|
||||||
<table class='w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400'>
|
|<a href="#basename">basename(path) -> string</a>|Returns the "basename," or the last part of the provided `path`. If path is empty,|
|
||||||
<tbody>
|
|<a href="#cd">cd(dir)</a>|Changes Hilbish's directory to `dir`.|
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
|<a href="#dir">dir(path) -> string</a>|Returns the directory part of `path`. If a file path like|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'><a href="#abs">abs(path) -> string</a></td>
|
|<a href="#glob">glob(pattern) -> matches (table)</a>|Match all files based on the provided `pattern`.|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Returns an absolute version of the `path`.</td>
|
|<a href="#join">join(...path) -> string</a>|Takes any list of paths and joins them based on the operating system's path separator.|
|
||||||
</tr>
|
|<a href="#mkdir">mkdir(name, recursive)</a>|Creates a new directory with the provided `name`.|
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
|<a href="#pipe">fpipe() -> File, File</a>|Returns a pair of connected files, also known as a pipe.|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'><a href="#basename">basename(path) -> string</a></td>
|
|<a href="#readdir">readdir(path) -> table[string]</a>|Returns a list of all files and directories in the provided path.|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Returns the "basename," or the last part of the provided `path`. If path is empty,</td>
|
|<a href="#stat">stat(path) -> {}</a>|Returns the information about a given `path`.|
|
||||||
</tr>
|
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'><a href="#cd">cd(dir)</a></td>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Changes Hilbish's directory to `dir`.</td>
|
|
||||||
</tr>
|
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'><a href="#dir">dir(path) -> string</a></td>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Returns the directory part of `path`. If a file path like</td>
|
|
||||||
</tr>
|
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'><a href="#glob">glob(pattern) -> matches (table)</a></td>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Match all files based on the provided `pattern`.</td>
|
|
||||||
</tr>
|
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'><a href="#join">join(...path) -> string</a></td>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Takes any list of paths and joins them based on the operating system's path separator.</td>
|
|
||||||
</tr>
|
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'><a href="#mkdir">mkdir(name, recursive)</a></td>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Creates a new directory with the provided `name`.</td>
|
|
||||||
</tr>
|
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'><a href="#pipe">fpipe() -> File, File</a></td>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Returns a pair of connected files, also known as a pipe.</td>
|
|
||||||
</tr>
|
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'><a href="#readdir">readdir(path) -> table[string]</a></td>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Returns a list of all files and directories in the provided path.</td>
|
|
||||||
</tr>
|
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'><a href="#stat">stat(path) -> {}</a></td>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Returns the information about a given `path`.</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
```
|
|
||||||
|
|
||||||
## Static module fields
|
## Static module fields
|
||||||
|
|||
|
||||||
|
|----|----|
|
||||||
|
|pathSep|The operating system's path separator.|
|
||||||
|
|
||||||
``` =html
|
<hr>
|
||||||
<div class='relative overflow-x-auto sm:rounded-lg my-4'>
|
|
||||||
<table class='w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400'>
|
|
||||||
<tbody>
|
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>pathSep</td>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>The operating system's path separator.</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
```
|
|
||||||
|
|
||||||
## Functions
|
|
||||||
|
|
||||||
``` =html
|
|
||||||
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
|
|
||||||
<div id='abs'>
|
<div id='abs'>
|
||||||
<h4 class='text-xl font-medium mb-2'>
|
<h4 class='heading'>
|
||||||
fs.abs(path) -> string
|
fs.abs(path) -> string
|
||||||
<a href="#abs" class='heading-link'>
|
<a href="#abs" class='heading-link'>
|
||||||
<i class="fas fa-paperclip"></i>
|
<i class="fas fa-paperclip"></i>
|
||||||
</a>
|
</a>
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
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*`
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
``` =html
|
|
||||||
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
|
|
||||||
<div id='basename'>
|
<div id='basename'>
|
||||||
<h4 class='text-xl font-medium mb-2'>
|
<h4 class='heading'>
|
||||||
fs.basename(path) -> string
|
fs.basename(path) -> string
|
||||||
<a href="#basename" class='heading-link'>
|
<a href="#basename" class='heading-link'>
|
||||||
<i class="fas fa-paperclip"></i>
|
<i class="fas fa-paperclip"></i>
|
||||||
</a>
|
</a>
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
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.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
``` =html
|
|
||||||
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
|
|
||||||
<div id='cd'>
|
<div id='cd'>
|
||||||
<h4 class='text-xl font-medium mb-2'>
|
<h4 class='heading'>
|
||||||
fs.cd(dir)
|
fs.cd(dir)
|
||||||
<a href="#cd" class='heading-link'>
|
<a href="#cd" class='heading-link'>
|
||||||
<i class="fas fa-paperclip"></i>
|
<i class="fas fa-paperclip"></i>
|
||||||
</a>
|
</a>
|
||||||
</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.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
``` =html
|
|
||||||
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
|
|
||||||
<div id='dir'>
|
<div id='dir'>
|
||||||
<h4 class='text-xl font-medium mb-2'>
|
<h4 class='heading'>
|
||||||
fs.dir(path) -> string
|
fs.dir(path) -> string
|
||||||
<a href="#dir" class='heading-link'>
|
<a href="#dir" class='heading-link'>
|
||||||
<i class="fas fa-paperclip"></i>
|
<i class="fas fa-paperclip"></i>
|
||||||
</a>
|
</a>
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
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.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
``` =html
|
|
||||||
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
|
|
||||||
<div id='glob'>
|
<div id='glob'>
|
||||||
<h4 class='text-xl font-medium mb-2'>
|
<h4 class='heading'>
|
||||||
fs.glob(pattern) -> matches (table)
|
fs.glob(pattern) -> matches (table)
|
||||||
<a href="#glob" class='heading-link'>
|
<a href="#glob" class='heading-link'>
|
||||||
<i class="fas fa-paperclip"></i>
|
<i class="fas fa-paperclip"></i>
|
||||||
</a>
|
</a>
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
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.
|
||||||
|
|
||||||
#### Example
|
#### Example
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
--[[
|
--[[
|
||||||
Within a folder that contains the following files:
|
Within a folder that contains the following files:
|
||||||
@ -203,121 +132,100 @@ local matches = fs.glob './*.lua'
|
|||||||
print(matches)
|
print(matches)
|
||||||
-- -> {'init.lua', 'code.lua'}
|
-- -> {'init.lua', 'code.lua'}
|
||||||
```
|
```
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
``` =html
|
|
||||||
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
|
|
||||||
<div id='join'>
|
<div id='join'>
|
||||||
<h4 class='text-xl font-medium mb-2'>
|
<h4 class='heading'>
|
||||||
fs.join(...path) -> string
|
fs.join(...path) -> string
|
||||||
<a href="#join" class='heading-link'>
|
<a href="#join" class='heading-link'>
|
||||||
<i class="fas fa-paperclip"></i>
|
<i class="fas fa-paperclip"></i>
|
||||||
</a>
|
</a>
|
||||||
</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
|
||||||
|
|
||||||
#### Example
|
#### Example
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- This prints the directory for Hilbish's config!
|
-- This prints the directory for Hilbish's config!
|
||||||
print(fs.join(hilbish.userDir.config, 'hilbish'))
|
print(fs.join(hilbish.userDir.config, 'hilbish'))
|
||||||
-- -> '/home/user/.config/hilbish' on Linux
|
-- -> '/home/user/.config/hilbish' on Linux
|
||||||
```
|
```
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
``` =html
|
|
||||||
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
|
|
||||||
<div id='mkdir'>
|
<div id='mkdir'>
|
||||||
<h4 class='text-xl font-medium mb-2'>
|
<h4 class='heading'>
|
||||||
fs.mkdir(name, recursive)
|
fs.mkdir(name, recursive)
|
||||||
<a href="#mkdir" class='heading-link'>
|
<a href="#mkdir" class='heading-link'>
|
||||||
<i class="fas fa-paperclip"></i>
|
<i class="fas fa-paperclip"></i>
|
||||||
</a>
|
</a>
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
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.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
`string` **`name`**
|
||||||
`string` `*name*`
|
|
||||||
Name of the directory
|
Name of the directory
|
||||||
|
|
||||||
`boolean` `*recursive*`
|
`boolean` **`recursive`**
|
||||||
Whether to create parent directories for the provided name
|
Whether to create parent directories for the provided name
|
||||||
|
|
||||||
#### Example
|
#### Example
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- 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)
|
||||||
```
|
```
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
``` =html
|
|
||||||
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
|
|
||||||
<div id='pipe'>
|
<div id='pipe'>
|
||||||
<h4 class='text-xl font-medium mb-2'>
|
<h4 class='heading'>
|
||||||
fs.fpipe() -> File, File
|
fs.fpipe() -> File, File
|
||||||
<a href="#pipe" class='heading-link'>
|
<a href="#pipe" class='heading-link'>
|
||||||
<i class="fas fa-paperclip"></i>
|
<i class="fas fa-paperclip"></i>
|
||||||
</a>
|
</a>
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
Returns a pair of connected files, also known as a pipe.
|
Returns a pair of connected files, also known as a pipe.
|
||||||
The type returned is a Lua file, same as returned from `io` functions.
|
The type returned is a Lua file, same as returned from `io` functions.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
``` =html
|
|
||||||
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
|
|
||||||
<div id='readdir'>
|
<div id='readdir'>
|
||||||
<h4 class='text-xl font-medium mb-2'>
|
<h4 class='heading'>
|
||||||
fs.readdir(path) -> table[string]
|
fs.readdir(path) -> table[string]
|
||||||
<a href="#readdir" class='heading-link'>
|
<a href="#readdir" class='heading-link'>
|
||||||
<i class="fas fa-paperclip"></i>
|
<i class="fas fa-paperclip"></i>
|
||||||
</a>
|
</a>
|
||||||
</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*`
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
``` =html
|
|
||||||
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
|
|
||||||
<div id='stat'>
|
<div id='stat'>
|
||||||
<h4 class='text-xl font-medium mb-2'>
|
<h4 class='heading'>
|
||||||
fs.stat(path) -> {}
|
fs.stat(path) -> {}
|
||||||
<a href="#stat" class='heading-link'>
|
<a href="#stat" class='heading-link'>
|
||||||
<i class="fas fa-paperclip"></i>
|
<i class="fas fa-paperclip"></i>
|
||||||
</a>
|
</a>
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
Returns the information about a given `path`.
|
Returns the information about a given `path`.
|
||||||
The returned table contains the following values:
|
The returned table contains the following values:
|
||||||
name (string) - Name of the path
|
name (string) - Name of the path
|
||||||
@ -326,12 +234,10 @@ 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*`
|
|
||||||
|
|
||||||
|
|
||||||
#### Example
|
#### Example
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local inspect = require 'inspect'
|
local inspect = require 'inspect'
|
||||||
|
|
||||||
@ -347,5 +253,5 @@ Would print the following:
|
|||||||
}
|
}
|
||||||
]]--
|
]]--
|
||||||
```
|
```
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
title: Module hilbish
|
title: Module hilbish
|
||||||
description: the core Hilbish API
|
description:
|
||||||
layout: doc
|
layout: doc
|
||||||
menu:
|
menu:
|
||||||
docs:
|
docs:
|
||||||
@ -9,153 +9,100 @@ menu:
|
|||||||
|
|
||||||
## Introduction
|
## Introduction
|
||||||
|
|
||||||
The Hilbish module includes the core API, containing
|
|
||||||
interfaces and functions which directly relate to shell functionality.
|
|
||||||
|
|
||||||
## Functions
|
## Functions
|
||||||
|
|
||||||
``` =html
|
``` =html
|
||||||
<div class='relative overflow-x-auto sm:rounded-lg my-4'>
|
<div class='p-2 rounded'>
|
||||||
<table class='w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400'>
|
<table class='w-full'>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
<tr class='m-2 bg-neutral-700'>
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'><a href="#alias">alias(cmd, orig)</a></td>
|
<td><a href="#alias">alias(cmd, orig)</a></td>
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Sets an alias, with a name of `cmd` to another command.</td>
|
<td>Sets an alias, with a name of `cmd` to another command.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
<tr class='m-2 bg-neutral-700'>
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'><a href="#appendPath">appendPath(dir)</a></td>
|
<td><a href="#appendPath">appendPath(dir)</a></td>
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Appends the provided dir to the command path (`$PATH`)</td>
|
<td>Appends the provided dir to the command path (`$PATH`)</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
<tr class='m-2 bg-neutral-700'>
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'><a href="#complete">complete(scope, cb)</a></td>
|
<td><a href="#complete">complete(scope, cb)</a></td>
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Registers a completion handler for the specified scope.</td>
|
<td>Registers a completion handler for the specified scope.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
<tr class='m-2 bg-neutral-700'>
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'><a href="#cwd">cwd() -> string</a></td>
|
<td><a href="#cwd">cwd() -> string</a></td>
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Returns the current directory of the shell.</td>
|
<td>Returns the current directory of the shell.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
<tr class='m-2 bg-neutral-700'>
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'><a href="#exec">exec(cmd)</a></td>
|
<td><a href="#exec">exec(cmd)</a></td>
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Replaces the currently running Hilbish instance with the supplied command.</td>
|
<td>Replaces the currently running Hilbish instance with the supplied command.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
<tr class='m-2 bg-neutral-700'>
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'><a href="#goro">goro(fn)</a></td>
|
<td><a href="#goro">goro(fn)</a></td>
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Puts `fn` in a Goroutine.</td>
|
<td>Puts `fn` in a Goroutine.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
<tr class='m-2 bg-neutral-700'>
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'><a href="#highlighter">highlighter(line)</a></td>
|
<td><a href="#highlighter">highlighter(line)</a></td>
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Line highlighter handler.</td>
|
<td>Line highlighter handler.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
<tr class='m-2 bg-neutral-700'>
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'><a href="#hinter">hinter(line, pos)</a></td>
|
<td><a href="#hinter">hinter(line, pos)</a></td>
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>The command line hint handler. It gets called on every key insert to</td>
|
<td>The command line hint handler. It gets called on every key insert to</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
<tr class='m-2 bg-neutral-700'>
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'><a href="#inputMode">inputMode(mode)</a></td>
|
<td><a href="#inputMode">inputMode(mode)</a></td>
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Sets the input mode for Hilbish's line reader.</td>
|
<td>Sets the input mode for Hilbish's line reader.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
<tr class='m-2 bg-neutral-700'>
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'><a href="#interval">interval(cb, time) -> @Timer</a></td>
|
<td><a href="#interval">interval(cb, time) -> @Timer</a></td>
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Runs the `cb` function every specified amount of `time`.</td>
|
<td>Runs the `cb` function every specified amount of `time`.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
<tr class='m-2 bg-neutral-700'>
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'><a href="#multiprompt">multiprompt(str)</a></td>
|
<td><a href="#multiprompt">multiprompt(str)</a></td>
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Changes the text prompt when Hilbish asks for more input.</td>
|
<td>Changes the text prompt when Hilbish asks for more input.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
<tr class='m-2 bg-neutral-700'>
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'><a href="#prependPath">prependPath(dir)</a></td>
|
<td><a href="#prependPath">prependPath(dir)</a></td>
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Prepends `dir` to $PATH.</td>
|
<td>Prepends `dir` to $PATH.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
<tr class='m-2 bg-neutral-700'>
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'><a href="#prompt">prompt(str, typ)</a></td>
|
<td><a href="#prompt">prompt(str, typ)</a></td>
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Changes the shell prompt to the provided string.</td>
|
<td>Changes the shell prompt to the provided string.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
<tr class='m-2 bg-neutral-700'>
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'><a href="#read">read(prompt) -> input (string)</a></td>
|
<td><a href="#read">read(prompt) -> input (string)</a></td>
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Read input from the user, using Hilbish's line editor/input reader.</td>
|
<td>Read input from the user, using Hilbish's line editor/input reader.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
<tr class='m-2 bg-neutral-700'>
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'><a href="#timeout">timeout(cb, time) -> @Timer</a></td>
|
<td><a href="#timeout">timeout(cb, time) -> @Timer</a></td>
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Executed the `cb` function after a period of `time`.</td>
|
<td>Executed the `cb` function after a period of `time`.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
<tr class='m-2 bg-neutral-700'>
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'><a href="#which">which(name) -> string</a></td>
|
<td><a href="#which">which(name) -> string</a></td>
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Checks if `name` is a valid command.</td>
|
<td>Checks if `name` is a valid command.</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
```
|
```
|
||||||
|
|
||||||
## Static module fields
|
<hr>
|
||||||
|
|
||||||
``` =html
|
|
||||||
<div class='relative overflow-x-auto sm:rounded-lg my-4'>
|
|
||||||
<table class='w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400'>
|
|
||||||
<tbody>
|
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>ver</td>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>The version of Hilbish</td>
|
|
||||||
</tr>
|
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>goVersion</td>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>The version of Go that Hilbish was compiled with</td>
|
|
||||||
</tr>
|
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>user</td>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Username of the user</td>
|
|
||||||
</tr>
|
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>host</td>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Hostname of the machine</td>
|
|
||||||
</tr>
|
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>dataDir</td>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Directory for Hilbish data files, including the docs and default modules</td>
|
|
||||||
</tr>
|
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>interactive</td>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Is Hilbish in an interactive shell?</td>
|
|
||||||
</tr>
|
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>login</td>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Is Hilbish the login shell?</td>
|
|
||||||
</tr>
|
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>vimMode</td>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Current Vim input mode of Hilbish (will be nil if not in Vim input mode)</td>
|
|
||||||
</tr>
|
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>exitCode</td>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Exit code of the last executed command</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
```
|
|
||||||
|
|
||||||
## Functions
|
|
||||||
|
|
||||||
``` =html
|
|
||||||
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
|
|
||||||
<div id='alias'>
|
<div id='alias'>
|
||||||
<h4 class='text-xl font-medium mb-2'>
|
<h4 class='heading'>
|
||||||
hilbish.alias(cmd, orig)
|
hilbish.alias(cmd, orig)
|
||||||
<a href="#alias" class='heading-link'>
|
<a href="#alias" class='heading-link'>
|
||||||
<i class="fas fa-paperclip"></i>
|
<i class="fas fa-paperclip"></i>
|
||||||
</a>
|
</a>
|
||||||
</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
|
||||||
|
|
||||||
`string` `*orig*`
|
`string` *`orig`*
|
||||||
Command that will be aliased
|
Command that will be aliased
|
||||||
|
|
||||||
#### Example
|
#### Example
|
||||||
@ -168,25 +115,22 @@ hilbish.alias('ga', 'git add')
|
|||||||
hilbish.alias('dircount', 'ls %1 | wc -l')
|
hilbish.alias('dircount', 'ls %1 | wc -l')
|
||||||
-- "dircount ~" would count how many files are in ~ (home directory).
|
-- "dircount ~" would count how many files are in ~ (home directory).
|
||||||
```
|
```
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
``` =html
|
|
||||||
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
|
|
||||||
<div id='appendPath'>
|
<div id='appendPath'>
|
||||||
<h4 class='text-xl font-medium mb-2'>
|
<h4 class='heading'>
|
||||||
hilbish.appendPath(dir)
|
hilbish.appendPath(dir)
|
||||||
<a href="#appendPath" class='heading-link'>
|
<a href="#appendPath" class='heading-link'>
|
||||||
<i class="fas fa-paperclip"></i>
|
<i class="fas fa-paperclip"></i>
|
||||||
</a>
|
</a>
|
||||||
</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
|
||||||
|
|
||||||
#### Example
|
#### Example
|
||||||
@ -201,20 +145,17 @@ hilbish.appendPath {
|
|||||||
'~/.local/bin'
|
'~/.local/bin'
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
``` =html
|
|
||||||
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
|
|
||||||
<div id='complete'>
|
<div id='complete'>
|
||||||
<h4 class='text-xl font-medium mb-2'>
|
<h4 class='heading'>
|
||||||
hilbish.complete(scope, cb)
|
hilbish.complete(scope, cb)
|
||||||
<a href="#complete" class='heading-link'>
|
<a href="#complete" class='heading-link'>
|
||||||
<i class="fas fa-paperclip"></i>
|
<i class="fas fa-paperclip"></i>
|
||||||
</a>
|
</a>
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
Registers a completion handler for the specified scope.
|
Registers a completion handler for the specified scope.
|
||||||
A `scope` is expected to be `command.<cmd>`,
|
A `scope` is 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`).
|
||||||
@ -223,10 +164,10 @@ provides more details.
|
|||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
`string` `*scope*`
|
`string` *`scope`*
|
||||||
|
|
||||||
|
|
||||||
`function` `*cb*`
|
`function` *`cb`*
|
||||||
|
|
||||||
|
|
||||||
#### Example
|
#### Example
|
||||||
@ -256,61 +197,52 @@ hilbish.complete('command.sudo', function(query, ctx, fields)
|
|||||||
return {compGroup}, pfx
|
return {compGroup}, pfx
|
||||||
end)
|
end)
|
||||||
```
|
```
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
``` =html
|
|
||||||
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
|
|
||||||
<div id='cwd'>
|
<div id='cwd'>
|
||||||
<h4 class='text-xl font-medium mb-2'>
|
<h4 class='heading'>
|
||||||
hilbish.cwd() -> string
|
hilbish.cwd() -> string
|
||||||
<a href="#cwd" class='heading-link'>
|
<a href="#cwd" class='heading-link'>
|
||||||
<i class="fas fa-paperclip"></i>
|
<i class="fas fa-paperclip"></i>
|
||||||
</a>
|
</a>
|
||||||
</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>
|
||||||
|
|
||||||
|
<hr>
|
||||||
``` =html
|
|
||||||
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
|
|
||||||
<div id='exec'>
|
<div id='exec'>
|
||||||
<h4 class='text-xl font-medium mb-2'>
|
<h4 class='heading'>
|
||||||
hilbish.exec(cmd)
|
hilbish.exec(cmd)
|
||||||
<a href="#exec" class='heading-link'>
|
<a href="#exec" class='heading-link'>
|
||||||
<i class="fas fa-paperclip"></i>
|
<i class="fas fa-paperclip"></i>
|
||||||
</a>
|
</a>
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
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`*
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
``` =html
|
|
||||||
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
|
|
||||||
<div id='goro'>
|
<div id='goro'>
|
||||||
<h4 class='text-xl font-medium mb-2'>
|
<h4 class='heading'>
|
||||||
hilbish.goro(fn)
|
hilbish.goro(fn)
|
||||||
<a href="#goro" class='heading-link'>
|
<a href="#goro" class='heading-link'>
|
||||||
<i class="fas fa-paperclip"></i>
|
<i class="fas fa-paperclip"></i>
|
||||||
</a>
|
</a>
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
Puts `fn` in a Goroutine.
|
Puts `fn` in a Goroutine.
|
||||||
This can be used to run any function in another thread at the same time as other Lua code.
|
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.**
|
**NOTE: THIS FUNCTION MAY CRASH HILBISH IF OUTSIDE VARIABLES ARE ACCESSED.**
|
||||||
@ -318,23 +250,20 @@ This can be used to run any function in another thread at the same time as other
|
|||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
`function` `*fn*`
|
`function` *`fn`*
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
``` =html
|
|
||||||
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
|
|
||||||
<div id='highlighter'>
|
<div id='highlighter'>
|
||||||
<h4 class='text-xl font-medium mb-2'>
|
<h4 class='heading'>
|
||||||
hilbish.highlighter(line)
|
hilbish.highlighter(line)
|
||||||
<a href="#highlighter" class='heading-link'>
|
<a href="#highlighter" class='heading-link'>
|
||||||
<i class="fas fa-paperclip"></i>
|
<i class="fas fa-paperclip"></i>
|
||||||
</a>
|
</a>
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
Line highlighter handler.
|
Line highlighter handler.
|
||||||
This is mainly for syntax highlighting, but in reality could set the input
|
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
|
||||||
@ -343,7 +272,7 @@ Note that to set a highlighter, one has to override this function.
|
|||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
`string` `*line*`
|
`string` *`line`*
|
||||||
|
|
||||||
|
|
||||||
#### Example
|
#### Example
|
||||||
@ -354,20 +283,17 @@ function hilbish.highlighter(line)
|
|||||||
return line:gsub('"%w+"', function(c) return lunacolors.green(c) end)
|
return line:gsub('"%w+"', function(c) return lunacolors.green(c) end)
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
``` =html
|
|
||||||
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
|
|
||||||
<div id='hinter'>
|
<div id='hinter'>
|
||||||
<h4 class='text-xl font-medium mb-2'>
|
<h4 class='heading'>
|
||||||
hilbish.hinter(line, pos)
|
hilbish.hinter(line, pos)
|
||||||
<a href="#hinter" class='heading-link'>
|
<a href="#hinter" class='heading-link'>
|
||||||
<i class="fas fa-paperclip"></i>
|
<i class="fas fa-paperclip"></i>
|
||||||
</a>
|
</a>
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
The command line hint handler. It gets called on every key insert to
|
The command line hint handler. It gets called on every key insert to
|
||||||
determine what text to use as an inline hint. It is passed the current
|
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
|
||||||
@ -376,10 +302,10 @@ override this function with your custom handler.
|
|||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
`string` `*line*`
|
`string` *`line`*
|
||||||
|
|
||||||
|
|
||||||
`number` `*pos*`
|
`number` *`pos`*
|
||||||
Position of cursor in line. Usually equals string.len(line)
|
Position of cursor in line. Usually equals string.len(line)
|
||||||
|
|
||||||
#### Example
|
#### Example
|
||||||
@ -390,74 +316,65 @@ function hilbish.hinter(line, pos)
|
|||||||
return 'hi'
|
return 'hi'
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
``` =html
|
|
||||||
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
|
|
||||||
<div id='inputMode'>
|
<div id='inputMode'>
|
||||||
<h4 class='text-xl font-medium mb-2'>
|
<h4 class='heading'>
|
||||||
hilbish.inputMode(mode)
|
hilbish.inputMode(mode)
|
||||||
<a href="#inputMode" class='heading-link'>
|
<a href="#inputMode" class='heading-link'>
|
||||||
<i class="fas fa-paperclip"></i>
|
<i class="fas fa-paperclip"></i>
|
||||||
</a>
|
</a>
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
Sets the input mode for Hilbish's line reader.
|
Sets the input mode for Hilbish's line reader.
|
||||||
`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`*
|
||||||
Can be set to either `emacs` or `vim`
|
Can be set to either `emacs` or `vim`
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
``` =html
|
|
||||||
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
|
|
||||||
<div id='interval'>
|
<div id='interval'>
|
||||||
<h4 class='text-xl font-medium mb-2'>
|
<h4 class='heading'>
|
||||||
hilbish.interval(cb, time) -> @Timer
|
hilbish.interval(cb, time) -> <a href="/Hilbish/docs/api/hilbish/hilbish.timers/#timer" style="text-decoration: none;" id="lol">Timer</a>
|
||||||
<a href="#interval" class='heading-link'>
|
<a href="#interval" class='heading-link'>
|
||||||
<i class="fas fa-paperclip"></i>
|
<i class="fas fa-paperclip"></i>
|
||||||
</a>
|
</a>
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
Runs the `cb` function every specified amount of `time`.
|
Runs the `cb` function every specified amount of `time`.
|
||||||
This creates a timer that ticking immediately.
|
This creates a timer that ticking immediately.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
`function` `*cb*`
|
`function` *`cb`*
|
||||||
|
|
||||||
|
|
||||||
`number` `*time*`
|
`number` *`time`*
|
||||||
Time in milliseconds.
|
Time in milliseconds.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
``` =html
|
|
||||||
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
|
|
||||||
<div id='multiprompt'>
|
<div id='multiprompt'>
|
||||||
<h4 class='text-xl font-medium mb-2'>
|
<h4 class='heading'>
|
||||||
hilbish.multiprompt(str)
|
hilbish.multiprompt(str)
|
||||||
<a href="#multiprompt" class='heading-link'>
|
<a href="#multiprompt" class='heading-link'>
|
||||||
<i class="fas fa-paperclip"></i>
|
<i class="fas fa-paperclip"></i>
|
||||||
</a>
|
</a>
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
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`*
|
||||||
|
|
||||||
|
|
||||||
#### Example
|
#### Example
|
||||||
@ -479,41 +396,35 @@ hey ...!
|
|||||||
]]--
|
]]--
|
||||||
hilbish.multiprompt '-->'
|
hilbish.multiprompt '-->'
|
||||||
```
|
```
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
``` =html
|
|
||||||
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
|
|
||||||
<div id='prependPath'>
|
<div id='prependPath'>
|
||||||
<h4 class='text-xl font-medium mb-2'>
|
<h4 class='heading'>
|
||||||
hilbish.prependPath(dir)
|
hilbish.prependPath(dir)
|
||||||
<a href="#prependPath" class='heading-link'>
|
<a href="#prependPath" class='heading-link'>
|
||||||
<i class="fas fa-paperclip"></i>
|
<i class="fas fa-paperclip"></i>
|
||||||
</a>
|
</a>
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
Prepends `dir` to $PATH.
|
Prepends `dir` to $PATH.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
`string` `*dir*`
|
`string` *`dir`*
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
``` =html
|
|
||||||
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
|
|
||||||
<div id='prompt'>
|
<div id='prompt'>
|
||||||
<h4 class='text-xl font-medium mb-2'>
|
<h4 class='heading'>
|
||||||
hilbish.prompt(str, typ)
|
hilbish.prompt(str, typ)
|
||||||
<a href="#prompt" class='heading-link'>
|
<a href="#prompt" class='heading-link'>
|
||||||
<i class="fas fa-paperclip"></i>
|
<i class="fas fa-paperclip"></i>
|
||||||
</a>
|
</a>
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
Changes the shell prompt to the provided string.
|
Changes the shell prompt to the provided string.
|
||||||
There are a few verbs that can be used in the prompt text.
|
There are a few verbs that can be used in the prompt text.
|
||||||
These will be formatted and replaced with the appropriate values.
|
These will be formatted and replaced with the appropriate values.
|
||||||
@ -523,10 +434,10 @@ These will be formatted and replaced with the appropriate values.
|
|||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
`string` `*str*`
|
`string` *`str`*
|
||||||
|
|
||||||
|
|
||||||
`string` `*typ?*`
|
`string` *`typ?`*
|
||||||
Type of prompt, being left or right. Left by default.
|
Type of prompt, being left or right. Left by default.
|
||||||
|
|
||||||
#### Example
|
#### Example
|
||||||
@ -538,83 +449,72 @@ hilbish.prompt '%u %d ∆'
|
|||||||
hilbish.prompt '%u@%h :%d $'
|
hilbish.prompt '%u@%h :%d $'
|
||||||
-- prompt: user@hostname: ~/directory $
|
-- prompt: user@hostname: ~/directory $
|
||||||
```
|
```
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
``` =html
|
|
||||||
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
|
|
||||||
<div id='read'>
|
<div id='read'>
|
||||||
<h4 class='text-xl font-medium mb-2'>
|
<h4 class='heading'>
|
||||||
hilbish.read(prompt) -> input (string)
|
hilbish.read(prompt) -> input (string)
|
||||||
<a href="#read" class='heading-link'>
|
<a href="#read" class='heading-link'>
|
||||||
<i class="fas fa-paperclip"></i>
|
<i class="fas fa-paperclip"></i>
|
||||||
</a>
|
</a>
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
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.
|
Returns `input`, will be nil if Ctrl-D is pressed, or an error occurs.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
`string` `*prompt?*`
|
`string` *`prompt?`*
|
||||||
Text to print before input, can be empty.
|
Text to print before input, can be empty.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
``` =html
|
|
||||||
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
|
|
||||||
<div id='timeout'>
|
<div id='timeout'>
|
||||||
<h4 class='text-xl font-medium mb-2'>
|
<h4 class='heading'>
|
||||||
hilbish.timeout(cb, time) -> @Timer
|
hilbish.timeout(cb, time) -> <a href="/Hilbish/docs/api/hilbish/hilbish.timers/#timer" style="text-decoration: none;" id="lol">Timer</a>
|
||||||
<a href="#timeout" class='heading-link'>
|
<a href="#timeout" class='heading-link'>
|
||||||
<i class="fas fa-paperclip"></i>
|
<i class="fas fa-paperclip"></i>
|
||||||
</a>
|
</a>
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
Executed the `cb` function after a period of `time`.
|
Executed the `cb` function after a period of `time`.
|
||||||
This creates a Timer that starts ticking immediately.
|
This creates a Timer that starts ticking immediately.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
`function` `*cb*`
|
`function` *`cb`*
|
||||||
|
|
||||||
|
|
||||||
`number` `*time*`
|
`number` *`time`*
|
||||||
Time to run in milliseconds.
|
Time to run in milliseconds.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
``` =html
|
|
||||||
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
|
|
||||||
<div id='which'>
|
<div id='which'>
|
||||||
<h4 class='text-xl font-medium mb-2'>
|
<h4 class='heading'>
|
||||||
hilbish.which(name) -> string
|
hilbish.which(name) -> string
|
||||||
<a href="#which" class='heading-link'>
|
<a href="#which" class='heading-link'>
|
||||||
<i class="fas fa-paperclip"></i>
|
<i class="fas fa-paperclip"></i>
|
||||||
</a>
|
</a>
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
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`*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
## Types
|
## Types
|
||||||
|
|
||||||
``` =html
|
<hr>
|
||||||
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
|
|
||||||
```
|
|
||||||
|
|
||||||
## Sink
|
## Sink
|
||||||
|
|
||||||
|
539
docs/api/hilbish/_index.md
Normal file
539
docs/api/hilbish/_index.md
Normal file
@ -0,0 +1,539 @@
|
|||||||
|
---
|
||||||
|
title: Module hilbish
|
||||||
|
description: the core Hilbish API
|
||||||
|
layout: doc
|
||||||
|
menu:
|
||||||
|
docs:
|
||||||
|
parent: "API"
|
||||||
|
---
|
||||||
|
|
||||||
|
## Introduction
|
||||||
|
The Hilbish module includes the core API, containing
|
||||||
|
interfaces and functions which directly relate to shell functionality.
|
||||||
|
|
||||||
|
## Functions
|
||||||
|
|||
|
||||||
|
|----|----|
|
||||||
|
|<a href="#alias">alias(cmd, orig)</a>|Sets an alias, with a name of `cmd` to another command.|
|
||||||
|
|<a href="#appendPath">appendPath(dir)</a>|Appends the provided dir to the command path (`$PATH`)|
|
||||||
|
|<a href="#complete">complete(scope, cb)</a>|Registers a completion handler for the specified scope.|
|
||||||
|
|<a href="#cwd">cwd() -> string</a>|Returns the current directory of the shell.|
|
||||||
|
|<a href="#exec">exec(cmd)</a>|Replaces the currently running Hilbish instance with the supplied command.|
|
||||||
|
|<a href="#goro">goro(fn)</a>|Puts `fn` in a Goroutine.|
|
||||||
|
|<a href="#highlighter">highlighter(line)</a>|Line highlighter handler.|
|
||||||
|
|<a href="#hinter">hinter(line, pos)</a>|The command line hint handler. It gets called on every key insert to|
|
||||||
|
|<a href="#inputMode">inputMode(mode)</a>|Sets the input mode for Hilbish's line reader.|
|
||||||
|
|<a href="#interval">interval(cb, time) -> @Timer</a>|Runs the `cb` function every specified amount of `time`.|
|
||||||
|
|<a href="#multiprompt">multiprompt(str)</a>|Changes the text prompt when Hilbish asks for more input.|
|
||||||
|
|<a href="#prependPath">prependPath(dir)</a>|Prepends `dir` to $PATH.|
|
||||||
|
|<a href="#prompt">prompt(str, typ)</a>|Changes the shell prompt to the provided string.|
|
||||||
|
|<a href="#read">read(prompt) -> input (string)</a>|Read input from the user, using Hilbish's line editor/input reader.|
|
||||||
|
|<a href="#timeout">timeout(cb, time) -> @Timer</a>|Executed the `cb` function after a period of `time`.|
|
||||||
|
|<a href="#which">which(name) -> string</a>|Checks if `name` is a valid command.|
|
||||||
|
|<a href="#runnerMode">runnerMode(mode)</a>|Sets the execution/runner mode for interactive Hilbish.|
|
||||||
|
|<a href="#run">run(cmd, streams)</a>|Runs `cmd` in Hilbish's shell script interpreter.|
|
||||||
|
|
||||||
|
## Static module fields
|
||||||
|
|||
|
||||||
|
|----|----|
|
||||||
|
|ver|The version of Hilbish|
|
||||||
|
|goVersion|The version of Go that Hilbish was compiled with|
|
||||||
|
|user|Username of the user|
|
||||||
|
|host|Hostname of the machine|
|
||||||
|
|dataDir|Directory for Hilbish data files, including the docs and default modules|
|
||||||
|
|interactive|Is Hilbish in an interactive shell?|
|
||||||
|
|login|Is Hilbish the login shell?|
|
||||||
|
|vimMode|Current Vim input mode of Hilbish (will be nil if not in Vim input mode)|
|
||||||
|
|exitCode|Exit code of the last executed command|
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='alias'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.alias(cmd, orig)
|
||||||
|
<a href="#alias" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Sets an alias, with a name of `cmd` to another command.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
`string` **`cmd`**
|
||||||
|
Name of the alias
|
||||||
|
|
||||||
|
`string` **`orig`**
|
||||||
|
Command that will be aliased
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
```lua
|
||||||
|
-- With this, "ga file" will turn into "git add file"
|
||||||
|
hilbish.alias('ga', 'git add')
|
||||||
|
|
||||||
|
-- Numbered substitutions are supported here!
|
||||||
|
hilbish.alias('dircount', 'ls %1 | wc -l')
|
||||||
|
-- "dircount ~" would count how many files are in ~ (home directory).
|
||||||
|
```
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='appendPath'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.appendPath(dir)
|
||||||
|
<a href="#appendPath" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Appends the provided dir to the command path (`$PATH`)
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
`string|table` **`dir`**
|
||||||
|
Directory (or directories) to append to path
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
```lua
|
||||||
|
hilbish.appendPath '~/go/bin'
|
||||||
|
-- Will add ~/go/bin to the command path.
|
||||||
|
|
||||||
|
-- Or do multiple:
|
||||||
|
hilbish.appendPath {
|
||||||
|
'~/go/bin',
|
||||||
|
'~/.local/bin'
|
||||||
|
}
|
||||||
|
```
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='complete'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.complete(scope, cb)
|
||||||
|
<a href="#complete" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Registers a completion handler for the specified scope.
|
||||||
|
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.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
`string` **`scope`**
|
||||||
|
|
||||||
|
|
||||||
|
`function` **`cb`**
|
||||||
|
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
```lua
|
||||||
|
-- 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
|
||||||
|
local comps, pfx = hilbish.completion.bins(query, ctx, fields)
|
||||||
|
local compGroup = {
|
||||||
|
items = comps, -- our list of items to complete
|
||||||
|
type = 'grid' -- what our completions will look like.
|
||||||
|
}
|
||||||
|
|
||||||
|
return {compGroup}, pfx
|
||||||
|
end
|
||||||
|
|
||||||
|
-- otherwise just be boring and return files
|
||||||
|
|
||||||
|
local comps, pfx = hilbish.completion.files(query, ctx, fields)
|
||||||
|
local compGroup = {
|
||||||
|
items = comps,
|
||||||
|
type = 'grid'
|
||||||
|
}
|
||||||
|
|
||||||
|
return {compGroup}, pfx
|
||||||
|
end)
|
||||||
|
```
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='cwd'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.cwd() -> string
|
||||||
|
<a href="#cwd" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Returns the current directory of the shell.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='exec'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.exec(cmd)
|
||||||
|
<a href="#exec" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Replaces the currently running Hilbish instance with the supplied command.
|
||||||
|
This can be used to do an in-place restart.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
`string` **`cmd`**
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='goro'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.goro(fn)
|
||||||
|
<a href="#goro" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
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`**
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='highlighter'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.highlighter(line)
|
||||||
|
<a href="#highlighter" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Line highlighter handler.
|
||||||
|
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
|
||||||
|
```lua
|
||||||
|
--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)
|
||||||
|
end
|
||||||
|
```
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='hinter'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.hinter(line, pos)
|
||||||
|
<a href="#hinter" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
The command line hint handler. It gets called on every key insert to
|
||||||
|
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`**
|
||||||
|
Position of cursor in line. Usually equals string.len(line)
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
```lua
|
||||||
|
-- this will display "hi" after the cursor in a dimmed color.
|
||||||
|
function hilbish.hinter(line, pos)
|
||||||
|
return 'hi'
|
||||||
|
end
|
||||||
|
```
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='inputMode'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.inputMode(mode)
|
||||||
|
<a href="#inputMode" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
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`**
|
||||||
|
Can be set to either `emacs` or `vim`
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='interval'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.interval(cb, time) -> <a href="/Hilbish/docs/api/hilbish/hilbish.timers/#timer" style="text-decoration: none;" id="lol">Timer</a>
|
||||||
|
<a href="#interval" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Runs the `cb` function every specified amount of `time`.
|
||||||
|
This creates a timer that ticking immediately.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
`function` **`cb`**
|
||||||
|
|
||||||
|
|
||||||
|
`number` **`time`**
|
||||||
|
Time in milliseconds.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='multiprompt'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.multiprompt(str)
|
||||||
|
<a href="#multiprompt" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
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
|
||||||
|
```lua
|
||||||
|
--[[
|
||||||
|
imagine this is your text input:
|
||||||
|
user ~ ∆ echo "hey
|
||||||
|
|
||||||
|
but there's a missing quote! hilbish will now prompt you so the terminal
|
||||||
|
will look like:
|
||||||
|
user ~ ∆ echo "hey
|
||||||
|
--> ...!"
|
||||||
|
|
||||||
|
so then you get
|
||||||
|
user ~ ∆ echo "hey
|
||||||
|
--> ...!"
|
||||||
|
hey ...!
|
||||||
|
]]--
|
||||||
|
hilbish.multiprompt '-->'
|
||||||
|
```
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='prependPath'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.prependPath(dir)
|
||||||
|
<a href="#prependPath" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Prepends `dir` to $PATH.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
`string` **`dir`**
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='prompt'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.prompt(str, typ)
|
||||||
|
<a href="#prompt" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Changes the shell prompt to the provided string.
|
||||||
|
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?`**
|
||||||
|
Type of prompt, being left or right. Left by default.
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
```lua
|
||||||
|
-- the default hilbish prompt without color
|
||||||
|
hilbish.prompt '%u %d ∆'
|
||||||
|
-- or something of old:
|
||||||
|
hilbish.prompt '%u@%h :%d $'
|
||||||
|
-- prompt: user@hostname: ~/directory $
|
||||||
|
```
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='read'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.read(prompt) -> input (string)
|
||||||
|
<a href="#read" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
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?`**
|
||||||
|
Text to print before input, can be empty.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='timeout'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.timeout(cb, time) -> <a href="/Hilbish/docs/api/hilbish/hilbish.timers/#timer" style="text-decoration: none;" id="lol">Timer</a>
|
||||||
|
<a href="#timeout" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Executed the `cb` function after a period of `time`.
|
||||||
|
This creates a Timer that starts ticking immediately.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
`function` **`cb`**
|
||||||
|
|
||||||
|
|
||||||
|
`number` **`time`**
|
||||||
|
Time to run in milliseconds.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='which'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.which(name) -> string
|
||||||
|
<a href="#which" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
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`**
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
## Types
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
## 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.
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='run'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.run(cmd, streams)
|
||||||
|
<a href="#run" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Runs `cmd` in Hilbish's shell script interpreter.
|
||||||
|
The `streams` parameter specifies the output and input streams the command should use.
|
||||||
|
For example, to write command output to a sink.
|
||||||
|
As a table, the caller can directly specify the standard output, error, and input
|
||||||
|
streams of the command with the table keys `out`, `err`, and `input` respectively.
|
||||||
|
As a boolean, it specifies whether the command should use standard output or return its output streams.
|
||||||
|
#### Parameters
|
||||||
|
`cmd` **`string`**
|
||||||
|
|
||||||
|
|
||||||
|
`streams` **`table|boolean`**
|
||||||
|
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
```lua
|
||||||
|
-- This code is the same as `ls -l | wc -l`
|
||||||
|
local fs = require 'fs'
|
||||||
|
local pr, pw = fs.pipe()
|
||||||
|
hilbish.run('ls -l', {
|
||||||
|
stdout = pw,
|
||||||
|
stderr = pw,
|
||||||
|
})
|
||||||
|
pw:close()
|
||||||
|
hilbish.run('wc -l', {
|
||||||
|
stdin = pr
|
||||||
|
})
|
||||||
|
```
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='runnerMode'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.runnerMode(mode)
|
||||||
|
<a href="#runnerMode" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Sets the execution/runner mode for interactive Hilbish.
|
||||||
|
**NOTE: This function is deprecated and will be removed in 3.0**
|
||||||
|
Use `hilbish.runner.setCurrent` instead.
|
||||||
|
This determines whether 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),
|
||||||
|
sh, and lua. It also accepts a function, to which if it is passed one
|
||||||
|
will call it to execute user input instead.
|
||||||
|
Read [about runner mode](../features/runner-mode) for more information.
|
||||||
|
#### Parameters
|
||||||
|
`mode` **`string|function`**
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
67
docs/api/hilbish/hilbish.abbr.md
Normal file
67
docs/api/hilbish/hilbish.abbr.md
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
---
|
||||||
|
title: Module hilbish.abbr
|
||||||
|
description: command line abbreviations
|
||||||
|
layout: doc
|
||||||
|
menu:
|
||||||
|
docs:
|
||||||
|
parent: "API"
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
## Introduction
|
||||||
|
The abbr module manages Hilbish abbreviations. These are words that can be replaced
|
||||||
|
with longer command line strings when entered.
|
||||||
|
As an example, `git push` can be abbreviated to `gp`. When the user types
|
||||||
|
`gp` into the command line, after hitting space or enter, it will expand to `git push`.
|
||||||
|
Abbreviations can be used as an alternative to aliases. They are saved entirely in the history
|
||||||
|
Instead of the aliased form of the same command.
|
||||||
|
|
||||||
|
## Functions
|
||||||
|
|||
|
||||||
|
|----|----|
|
||||||
|
|<a href="#remove">remove(abbr)</a>|Removes the named `abbr`.|
|
||||||
|
|<a href="#add">add(abbr, expanded|function, opts)</a>|Adds an abbreviation. The `abbr` is the abbreviation itself,|
|
||||||
|
<hr>
|
||||||
|
<div id='add'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.abbr.add(abbr, expanded|function, opts)
|
||||||
|
<a href="#add" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Adds an abbreviation. The `abbr` is the abbreviation itself,
|
||||||
|
while `expanded` is what the abbreviation should expand to.
|
||||||
|
It can be either a function or a string. If it is a function, it will expand to what
|
||||||
|
the function returns.
|
||||||
|
`opts` is a table that accepts 1 key: `anywhere`.
|
||||||
|
`opts.anywhere` defines whether the abbr expands anywhere in the command line or not,
|
||||||
|
whereas the default behavior is only at the beginning of the line
|
||||||
|
#### Parameters
|
||||||
|
`abbr` **`string`**
|
||||||
|
|
||||||
|
|
||||||
|
`expanded|function` **`string`**
|
||||||
|
|
||||||
|
|
||||||
|
`opts` **`table`**
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='remove'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.abbr.remove(abbr)
|
||||||
|
<a href="#remove" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Removes the named `abbr`.
|
||||||
|
#### Parameters
|
||||||
|
`abbr` **`string`**
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
91
docs/api/hilbish/hilbish.aliases.md
Normal file
91
docs/api/hilbish/hilbish.aliases.md
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
---
|
||||||
|
title: Module hilbish.aliases
|
||||||
|
description: command aliasing
|
||||||
|
layout: doc
|
||||||
|
menu:
|
||||||
|
docs:
|
||||||
|
parent: "API"
|
||||||
|
---
|
||||||
|
|
||||||
|
## Introduction
|
||||||
|
The alias interface deals with all command aliases in Hilbish.
|
||||||
|
|
||||||
|
## Functions
|
||||||
|
|||
|
||||||
|
|----|----|
|
||||||
|
|<a href="#aliases.add">add(alias, cmd)</a>|This is an alias (ha) for the [hilbish.alias](../#alias) function.|
|
||||||
|
|<a href="#aliases.delete">delete(name)</a>|Removes an alias.|
|
||||||
|
|<a href="#aliases.list">list() -> table[string, string]</a>|Get a table of all aliases, with string keys as the alias and the value as the command.|
|
||||||
|
|<a href="#aliases.resolve">resolve(alias) -> string?</a>|Resolves an alias to its original command. Will thrown an error if the alias doesn't exist.|
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='aliases.add'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.aliases.add(alias, cmd)
|
||||||
|
<a href="#aliases.add" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
This is an alias (ha) for the [hilbish.alias](../#alias) function.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='aliases.delete'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.aliases.delete(name)
|
||||||
|
<a href="#aliases.delete" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Removes an alias.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
`string` **`name`**
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='aliases.list'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.aliases.list() -> table[string, string]
|
||||||
|
<a href="#aliases.list" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Get a table of all aliases, with string keys as the alias and the value as the command.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
This function has no parameters.
|
||||||
|
#### Example
|
||||||
|
```lua
|
||||||
|
hilbish.aliases.add('hi', 'echo hi')
|
||||||
|
|
||||||
|
local aliases = hilbish.aliases.list()
|
||||||
|
-- -> {hi = 'echo hi'}
|
||||||
|
```
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='aliases.resolve'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.aliases.resolve(alias) -> string?
|
||||||
|
<a href="#aliases.resolve" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Resolves an alias to its original command. Will thrown an error if the alias doesn't exist.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
`string` **`alias`**
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
149
docs/api/hilbish/hilbish.completion.md
Normal file
149
docs/api/hilbish/hilbish.completion.md
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
---
|
||||||
|
title: Module hilbish.completion
|
||||||
|
description: tab completions
|
||||||
|
layout: doc
|
||||||
|
menu:
|
||||||
|
docs:
|
||||||
|
parent: "API"
|
||||||
|
---
|
||||||
|
|
||||||
|
## Introduction
|
||||||
|
The completions interface deals with tab completions.
|
||||||
|
|
||||||
|
## Functions
|
||||||
|
|||
|
||||||
|
|----|----|
|
||||||
|
|<a href="#completion.bins">bins(query, ctx, fields) -> entries (table), prefix (string)</a>|Return binaries/executables based on the provided parameters.|
|
||||||
|
|<a href="#completion.call">call(name, query, ctx, fields) -> completionGroups (table), prefix (string)</a>|Calls a completer function. This is mainly used to call a command completer, which will have a `name`|
|
||||||
|
|<a href="#completion.files">files(query, ctx, fields) -> entries (table), prefix (string)</a>|Returns file matches based on the provided parameters.|
|
||||||
|
|<a href="#completion.handler">handler(line, pos)</a>|This function contains the general completion handler for Hilbish. This function handles|
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='completion.bins'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.completion.bins(query, ctx, fields) -> entries (table), prefix (string)
|
||||||
|
<a href="#completion.bins" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Return binaries/executables based on the provided parameters.
|
||||||
|
This function is meant to be used as a helper in a command completion handler.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
`string` **`query`**
|
||||||
|
|
||||||
|
|
||||||
|
`string` **`ctx`**
|
||||||
|
|
||||||
|
|
||||||
|
`table` **`fields`**
|
||||||
|
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
```lua
|
||||||
|
-- an extremely simple completer for sudo.
|
||||||
|
hilbish.complete('command.sudo', function(query, ctx, fields)
|
||||||
|
table.remove(fields, 1)
|
||||||
|
if #fields[1] then
|
||||||
|
-- return commands because sudo runs a command as root..!
|
||||||
|
|
||||||
|
local entries, pfx = hilbish.completion.bins(query, ctx, fields)
|
||||||
|
return {
|
||||||
|
type = 'grid',
|
||||||
|
items = entries
|
||||||
|
}, pfx
|
||||||
|
end
|
||||||
|
|
||||||
|
-- ... else suggest files or anything else ..
|
||||||
|
end)
|
||||||
|
```
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='completion.call'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.completion.call(name, query, ctx, fields) -> completionGroups (table), prefix (string)
|
||||||
|
<a href="#completion.call" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
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`.
|
||||||
|
You can check the Completions doc or `doc completions` for info on the `completionGroups` return value.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
`string` **`name`**
|
||||||
|
|
||||||
|
|
||||||
|
`string` **`query`**
|
||||||
|
|
||||||
|
|
||||||
|
`string` **`ctx`**
|
||||||
|
|
||||||
|
|
||||||
|
`table` **`fields`**
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='completion.files'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.completion.files(query, ctx, fields) -> entries (table), prefix (string)
|
||||||
|
<a href="#completion.files" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Returns file matches based on the provided parameters.
|
||||||
|
This function is meant to be used as a helper in a command completion handler.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
`string` **`query`**
|
||||||
|
|
||||||
|
|
||||||
|
`string` **`ctx`**
|
||||||
|
|
||||||
|
|
||||||
|
`table` **`fields`**
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='completion.handler'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.completion.handler(line, pos)
|
||||||
|
<a href="#completion.handler" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
This function contains the general completion handler for Hilbish. This function handles
|
||||||
|
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.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
`string` **`line`**
|
||||||
|
The current Hilbish command line
|
||||||
|
|
||||||
|
`number` **`pos`**
|
||||||
|
Numerical position of the cursor
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
```lua
|
||||||
|
-- stripped down version of the default implementation
|
||||||
|
function hilbish.completion.handler(line, pos)
|
||||||
|
local query = fields[#fields]
|
||||||
|
|
||||||
|
if #fields == 1 then
|
||||||
|
-- call bins handler here
|
||||||
|
else
|
||||||
|
-- call command completer or files completer here
|
||||||
|
end
|
||||||
|
end
|
||||||
|
```
|
||||||
|
</div>
|
||||||
|
|
124
docs/api/hilbish/hilbish.editor.md
Normal file
124
docs/api/hilbish/hilbish.editor.md
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
---
|
||||||
|
title: Module hilbish.editor
|
||||||
|
description: interactions for Hilbish's line reader
|
||||||
|
layout: doc
|
||||||
|
menu:
|
||||||
|
docs:
|
||||||
|
parent: "API"
|
||||||
|
---
|
||||||
|
|
||||||
|
## Introduction
|
||||||
|
The hilbish.editor interface provides functions to
|
||||||
|
directly interact with the line editor in use.
|
||||||
|
|
||||||
|
## Functions
|
||||||
|
|||
|
||||||
|
|----|----|
|
||||||
|
|<a href="#editor.deleteByAmount">deleteByAmount(amount)</a>|Deletes characters in the line by the given amount.|
|
||||||
|
|<a href="#editor.getLine">getLine() -> string</a>|Returns the current input line.|
|
||||||
|
|<a href="#editor.getVimRegister">getVimRegister(register) -> string</a>|Returns the text that is at the register.|
|
||||||
|
|<a href="#editor.insert">insert(text)</a>|Inserts text into the Hilbish command line.|
|
||||||
|
|<a href="#editor.getChar">getChar() -> string</a>|Reads a keystroke from the user. This is in a format of something like Ctrl-L.|
|
||||||
|
|<a href="#editor.setVimRegister">setVimRegister(register, text)</a>|Sets the vim register at `register` to hold the passed text.|
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='editor.deleteByAmount'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.editor.deleteByAmount(amount)
|
||||||
|
<a href="#editor.deleteByAmount" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Deletes characters in the line by the given amount.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
`number` **`amount`**
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='editor.getLine'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.editor.getLine() -> string
|
||||||
|
<a href="#editor.getLine" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Returns the current input line.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='editor.getVimRegister'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.editor.getVimRegister(register) -> string
|
||||||
|
<a href="#editor.getVimRegister" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Returns the text that is at the register.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
`string` **`register`**
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='editor.insert'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.editor.insert(text)
|
||||||
|
<a href="#editor.insert" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Inserts text into the Hilbish command line.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
`string` **`text`**
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='editor.getChar'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.editor.getChar() -> string
|
||||||
|
<a href="#editor.getChar" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Reads a keystroke from the user. This is in a format of something like Ctrl-L.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='editor.setVimRegister'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.editor.setVimRegister(register, text)
|
||||||
|
<a href="#editor.setVimRegister" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Sets the vim register at `register` to hold the passed text.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
`string` **`register`**
|
||||||
|
|
||||||
|
|
||||||
|
`string` **`text`**
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
102
docs/api/hilbish/hilbish.history.md
Normal file
102
docs/api/hilbish/hilbish.history.md
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
---
|
||||||
|
title: Module hilbish.history
|
||||||
|
description: command history
|
||||||
|
layout: doc
|
||||||
|
menu:
|
||||||
|
docs:
|
||||||
|
parent: "API"
|
||||||
|
---
|
||||||
|
|
||||||
|
## Introduction
|
||||||
|
The history interface deals with command history.
|
||||||
|
This includes the ability to override functions to change the main
|
||||||
|
method of saving history.
|
||||||
|
|
||||||
|
## Functions
|
||||||
|
|||
|
||||||
|
|----|----|
|
||||||
|
|<a href="#history.add">add(cmd)</a>|Adds a command to the history.|
|
||||||
|
|<a href="#history.all">all() -> table</a>|Retrieves all history as a table.|
|
||||||
|
|<a href="#history.clear">clear()</a>|Deletes all commands from the history.|
|
||||||
|
|<a href="#history.get">get(index)</a>|Retrieves a command from the history based on the `index`.|
|
||||||
|
|<a href="#history.size">size() -> number</a>|Returns the amount of commands in the history.|
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='history.add'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.history.add(cmd)
|
||||||
|
<a href="#history.add" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Adds a command to the history.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
`string` **`cmd`**
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='history.all'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.history.all() -> table
|
||||||
|
<a href="#history.all" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Retrieves all history as a table.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='history.clear'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.history.clear()
|
||||||
|
<a href="#history.clear" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Deletes all commands from the history.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='history.get'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.history.get(index)
|
||||||
|
<a href="#history.get" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Retrieves a command from the history based on the `index`.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
`number` **`index`**
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='history.size'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.history.size() -> number
|
||||||
|
<a href="#history.size" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Returns the amount of commands in the history.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
146
docs/api/hilbish/hilbish.jobs.md
Normal file
146
docs/api/hilbish/hilbish.jobs.md
Normal file
@ -0,0 +1,146 @@
|
|||||||
|
---
|
||||||
|
title: Module hilbish.jobs
|
||||||
|
description: background job management
|
||||||
|
layout: doc
|
||||||
|
menu:
|
||||||
|
docs:
|
||||||
|
parent: "API"
|
||||||
|
---
|
||||||
|
|
||||||
|
## Introduction
|
||||||
|
|
||||||
|
Manage interactive jobs in Hilbish via Lua.
|
||||||
|
|
||||||
|
Jobs are the name of background tasks/commands. A job can be started via
|
||||||
|
interactive usage or with the functions defined below for use in external runners.
|
||||||
|
|
||||||
|
## Functions
|
||||||
|
|||
|
||||||
|
|----|----|
|
||||||
|
|<a href="#jobs.add">add(cmdstr, args, execPath)</a>|Creates a new job. This function does not run the job. This function is intended to be|
|
||||||
|
|<a href="#jobs.all">all() -> table[@Job]</a>|Returns a table of all job objects.|
|
||||||
|
|<a href="#jobs.disown">disown(id)</a>|Disowns a job. This simply deletes it from the list of jobs without stopping it.|
|
||||||
|
|<a href="#jobs.get">get(id) -> @Job</a>|Get a job object via its ID.|
|
||||||
|
|<a href="#jobs.last">last() -> @Job</a>|Returns the last added job to the table.|
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='jobs.add'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.jobs.add(cmdstr, args, execPath)
|
||||||
|
<a href="#jobs.add" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
`string` **`cmdstr`**
|
||||||
|
String that a user would write for the job
|
||||||
|
|
||||||
|
`table` **`args`**
|
||||||
|
Arguments for the commands. Has to include the name of the command.
|
||||||
|
|
||||||
|
`string` **`execPath`**
|
||||||
|
Binary to use to run the command. Needs to be an absolute path.
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
```lua
|
||||||
|
hilbish.jobs.add('go build', {'go', 'build'}, '/usr/bin/go')
|
||||||
|
```
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='jobs.all'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.jobs.all() -> table[<a href="/Hilbish/docs/api/hilbish/hilbish.jobs/#job" style="text-decoration: none;" id="lol">Job</a>]
|
||||||
|
<a href="#jobs.all" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Returns a table of all job objects.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='jobs.disown'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.jobs.disown(id)
|
||||||
|
<a href="#jobs.disown" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Disowns a job. This simply deletes it from the list of jobs without stopping it.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
`number` **`id`**
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='jobs.get'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.jobs.get(id) -> <a href="/Hilbish/docs/api/hilbish/hilbish.jobs/#job" style="text-decoration: none;" id="lol">Job</a>
|
||||||
|
<a href="#jobs.get" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Get a job object via its ID.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='jobs.last'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.jobs.last() -> <a href="/Hilbish/docs/api/hilbish/hilbish.jobs/#job" style="text-decoration: none;" id="lol">Job</a>
|
||||||
|
<a href="#jobs.last" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Returns the last added job to the table.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
## Types
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
## Job
|
||||||
|
The Job type describes a Hilbish job.
|
||||||
|
## Object properties
|
||||||
|
|||
|
||||||
|
|----|----|
|
||||||
|
|cmd|The user entered command string for the job.|
|
||||||
|
|running|Whether the job is running or not.|
|
||||||
|
|id|The ID of the job in the job table|
|
||||||
|
|pid|The Process ID|
|
||||||
|
|exitCode|The last exit code of the job.|
|
||||||
|
|stdout|The standard output of the job. This just means the normal logs of the process.|
|
||||||
|
|stderr|The standard error stream of the process. This (usually) includes error messages of the job.|
|
||||||
|
|
||||||
|
|
||||||
|
### Methods
|
||||||
|
#### background()
|
||||||
|
Puts a job in the background. This acts the same as initially running a job.
|
||||||
|
|
||||||
|
#### foreground()
|
||||||
|
Puts a job in the foreground. This will cause it to run like it was
|
||||||
|
executed normally and wait for it to complete.
|
||||||
|
|
||||||
|
#### start()
|
||||||
|
Starts running the job.
|
||||||
|
|
||||||
|
#### stop()
|
||||||
|
Stops the job from running.
|
||||||
|
|
135
docs/api/hilbish/hilbish.messages.md
Normal file
135
docs/api/hilbish/hilbish.messages.md
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
---
|
||||||
|
title: Module hilbish.messages
|
||||||
|
description: simplistic message passing
|
||||||
|
layout: doc
|
||||||
|
menu:
|
||||||
|
docs:
|
||||||
|
parent: "API"
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
## Introduction
|
||||||
|
The messages interface defines a way for Hilbish-integrated commands,
|
||||||
|
user config and other tasks to send notifications to alert the user.z
|
||||||
|
The `hilbish.message` type is a table with the following keys:
|
||||||
|
`title` (string): A title for the message notification.
|
||||||
|
`text` (string): The contents of the message.
|
||||||
|
`channel` (string): States the origin of the message, `hilbish.*` is reserved for Hilbish tasks.
|
||||||
|
`summary` (string): A short summary of the `text`.
|
||||||
|
`icon` (string): Unicode (preferably standard emoji) icon for the message notification
|
||||||
|
`read` (boolean): Whether the full message has been read or not.
|
||||||
|
|
||||||
|
## Functions
|
||||||
|
|||
|
||||||
|
|----|----|
|
||||||
|
|<a href="#unreadCount">unreadCount()</a>|Returns the amount of unread messages.|
|
||||||
|
|<a href="#send">send(message)</a>|Sends a message.|
|
||||||
|
|<a href="#readAll">readAll()</a>|Marks all messages as read.|
|
||||||
|
|<a href="#read">read(idx)</a>|Marks a message at `idx` as read.|
|
||||||
|
|<a href="#delete">delete(idx)</a>|Deletes the message at `idx`.|
|
||||||
|
|<a href="#clear">clear()</a>|Deletes all messages.|
|
||||||
|
|<a href="#all">all()</a>|Returns all messages.|
|
||||||
|
<hr>
|
||||||
|
<div id='all'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.messages.all()
|
||||||
|
<a href="#all" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Returns all messages.
|
||||||
|
#### Parameters
|
||||||
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='clear'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.messages.clear()
|
||||||
|
<a href="#clear" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Deletes all messages.
|
||||||
|
#### Parameters
|
||||||
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='delete'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.messages.delete(idx)
|
||||||
|
<a href="#delete" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Deletes the message at `idx`.
|
||||||
|
#### Parameters
|
||||||
|
`idx` **`number`**
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='read'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.messages.read(idx)
|
||||||
|
<a href="#read" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Marks a message at `idx` as read.
|
||||||
|
#### Parameters
|
||||||
|
`idx` **`number`**
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='readAll'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.messages.readAll()
|
||||||
|
<a href="#readAll" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Marks all messages as read.
|
||||||
|
#### Parameters
|
||||||
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='send'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.messages.send(message)
|
||||||
|
<a href="#send" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Sends a message.
|
||||||
|
#### Parameters
|
||||||
|
`message` **`hilbish.message`**
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='unreadCount'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.messages.unreadCount()
|
||||||
|
<a href="#unreadCount" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Returns the amount of unread messages.
|
||||||
|
#### Parameters
|
||||||
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
73
docs/api/hilbish/hilbish.module.md
Normal file
73
docs/api/hilbish/hilbish.module.md
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
---
|
||||||
|
title: Module hilbish.module
|
||||||
|
description: native module loading
|
||||||
|
layout: doc
|
||||||
|
menu:
|
||||||
|
docs:
|
||||||
|
parent: "API"
|
||||||
|
---
|
||||||
|
|
||||||
|
## Introduction
|
||||||
|
|
||||||
|
The hilbish.module interface provides a function to load
|
||||||
|
Hilbish plugins/modules. Hilbish modules are Go-written
|
||||||
|
plugins (see https://pkg.go.dev/plugin) that are used to add functionality
|
||||||
|
to Hilbish that cannot be written in Lua for any reason.
|
||||||
|
|
||||||
|
Note that you don't ever need to use the load function that is here as
|
||||||
|
modules can be loaded with a `require` call like Lua C modules, and the
|
||||||
|
search paths can be changed with the `paths` property here.
|
||||||
|
|
||||||
|
To make a valid native module, the Go plugin has to export a Loader function
|
||||||
|
with a signature like so: `func(*rt.Runtime) rt.Value`.
|
||||||
|
|
||||||
|
`rt` in this case refers to the Runtime type at
|
||||||
|
https://pkg.go.dev/github.com/arnodel/golua@master/runtime#Runtime
|
||||||
|
|
||||||
|
Hilbish uses this package as its Lua runtime. You will need to read
|
||||||
|
it to use it for a native plugin.
|
||||||
|
|
||||||
|
Here is some code for an example plugin:
|
||||||
|
```go
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
rt "github.com/arnodel/golua/runtime"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Loader(rtm *rt.Runtime) rt.Value {
|
||||||
|
return rt.StringValue("hello world!")
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
This can be compiled with `go build -buildmode=plugin plugin.go`.
|
||||||
|
If you attempt to require and print the result (`print(require 'plugin')`), it will show "hello world!"
|
||||||
|
|
||||||
|
## Functions
|
||||||
|
|||
|
||||||
|
|----|----|
|
||||||
|
|<a href="#module.load">load(path)</a>|Loads a module at the designated `path`.|
|
||||||
|
|
||||||
|
## Static module fields
|
||||||
|
|||
|
||||||
|
|----|----|
|
||||||
|
|paths|A list of paths to search when loading native modules. This is in the style of Lua search paths and will be used when requiring native modules. Example: `?.so;?/?.so`|
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='module.load'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.module.load(path)
|
||||||
|
<a href="#module.load" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Loads a module at the designated `path`.
|
||||||
|
It will throw if any error occurs.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
`string` **`path`**
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
20
docs/api/hilbish/hilbish.os.md
Normal file
20
docs/api/hilbish/hilbish.os.md
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
title: Module hilbish.os
|
||||||
|
description: operating system info
|
||||||
|
layout: doc
|
||||||
|
menu:
|
||||||
|
docs:
|
||||||
|
parent: "API"
|
||||||
|
---
|
||||||
|
|
||||||
|
## Introduction
|
||||||
|
Provides simple text information properties about the current operating system.
|
||||||
|
This mainly includes the name and version.
|
||||||
|
|
||||||
|
## Static module fields
|
||||||
|
|||
|
||||||
|
|----|----|
|
||||||
|
|family|Family name of the current OS|
|
||||||
|
|name|Pretty name of the current OS|
|
||||||
|
|version|Version of the current OS|
|
||||||
|
|
247
docs/api/hilbish/hilbish.runner.md
Normal file
247
docs/api/hilbish/hilbish.runner.md
Normal file
@ -0,0 +1,247 @@
|
|||||||
|
---
|
||||||
|
title: Module hilbish.runner
|
||||||
|
description: interactive command runner customization
|
||||||
|
layout: doc
|
||||||
|
menu:
|
||||||
|
docs:
|
||||||
|
parent: "API"
|
||||||
|
---
|
||||||
|
|
||||||
|
## Introduction
|
||||||
|
The runner interface contains functions that allow the user to change
|
||||||
|
how Hilbish interprets interactive input.
|
||||||
|
Users can add and change the default runner for interactive input to any
|
||||||
|
language or script of their choosing. A good example is using it to
|
||||||
|
write command in Fennel.
|
||||||
|
|
||||||
|
Runners are functions that evaluate user input. The default runners in
|
||||||
|
Hilbish can run shell script and Lua code.
|
||||||
|
|
||||||
|
A runner is passed the input and has to return a table with these values.
|
||||||
|
All are not required, only the useful ones the runner needs to return.
|
||||||
|
(So if there isn't an error, just omit `err`.)
|
||||||
|
|
||||||
|
- `exitCode` (number): Exit code of the command
|
||||||
|
- `input` (string): The text input of the user. This is used by Hilbish to append extra input, in case
|
||||||
|
more is requested.
|
||||||
|
- `err` (string): A string that represents an error from the runner.
|
||||||
|
This should only be set when, for example, there is a syntax error.
|
||||||
|
It can be set to a few special values for Hilbish to throw the right
|
||||||
|
hooks and have a better looking message.
|
||||||
|
- `\<command>: not-found` will throw a `command.not-found` hook
|
||||||
|
based on what `\<command>` is.
|
||||||
|
- `\<command>: not-executable` will throw a `command.not-executable` hook.
|
||||||
|
- `continue` (boolean): Whether Hilbish should prompt the user for no input
|
||||||
|
- `newline` (boolean): Whether a newline should be added at the end of `input`.
|
||||||
|
|
||||||
|
Here is a simple example of a fennel runner. It falls back to
|
||||||
|
shell script if fennel eval has an error.
|
||||||
|
```lua
|
||||||
|
local fennel = require 'fennel'
|
||||||
|
|
||||||
|
hilbish.runnerMode(function(input)
|
||||||
|
local ok = pcall(fennel.eval, input)
|
||||||
|
if ok then
|
||||||
|
return {
|
||||||
|
input = input
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
return hilbish.runner.sh(input)
|
||||||
|
end)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Functions
|
||||||
|
|||
|
||||||
|
|----|----|
|
||||||
|
|<a href="#runner.lua">lua(cmd)</a>|Evaluates `cmd` as Lua input. This is the same as using `dofile`|
|
||||||
|
|<a href="#sh">sh()</a>|nil|
|
||||||
|
|<a href="#setMode">setMode(mode)</a>|**NOTE: This function is deprecated and will be removed in 3.0**|
|
||||||
|
|<a href="#setCurrent">setCurrent(name)</a>|Sets Hilbish's runner mode by name.|
|
||||||
|
|<a href="#set">set(name, runner)</a>|*Sets* a runner by name. The difference between this function and|
|
||||||
|
|<a href="#run">run(input, priv)</a>|Runs `input` with the currently set Hilbish runner.|
|
||||||
|
|<a href="#getCurrent">getCurrent()</a>|Returns the current runner by name.|
|
||||||
|
|<a href="#get">get(name)</a>|Get a runner by name.|
|
||||||
|
|<a href="#exec">exec(cmd, runnerName)</a>|Executes `cmd` with a runner.|
|
||||||
|
|<a href="#add">add(name, runner)</a>|Adds a runner to the table of available runners.|
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='runner.lua'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.runner.lua(cmd)
|
||||||
|
<a href="#runner.lua" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Evaluates `cmd` as Lua input. This is the same as using `dofile`
|
||||||
|
or `load`, but is appropriated for the runner interface.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
`string` **`cmd`**
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='add'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.runner.add(name, runner)
|
||||||
|
<a href="#add" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Adds a runner to the table of available runners.
|
||||||
|
If runner is a table, it must have the run function in it.
|
||||||
|
#### Parameters
|
||||||
|
`name` **`string`**
|
||||||
|
Name of the runner
|
||||||
|
|
||||||
|
`runner` **`function|table`**
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='exec'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.runner.exec(cmd, runnerName)
|
||||||
|
<a href="#exec" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Executes `cmd` with a runner.
|
||||||
|
If `runnerName` is not specified, it uses the default Hilbish runner.
|
||||||
|
#### Parameters
|
||||||
|
`cmd` **`string`**
|
||||||
|
|
||||||
|
|
||||||
|
`runnerName` **`string?`**
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='get'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.runner.get(name)
|
||||||
|
<a href="#get" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Get a runner by name.
|
||||||
|
#### Parameters
|
||||||
|
`name` **`string`**
|
||||||
|
Name of the runner to retrieve.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='getCurrent'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.runner.getCurrent()
|
||||||
|
<a href="#getCurrent" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Returns the current runner by name.
|
||||||
|
#### Parameters
|
||||||
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='run'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.runner.run(input, priv)
|
||||||
|
<a href="#run" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Runs `input` with the currently set Hilbish runner.
|
||||||
|
This method is how Hilbish executes commands.
|
||||||
|
`priv` is an optional boolean used to state if the input should be saved to history.
|
||||||
|
#### Parameters
|
||||||
|
`input` **`string`**
|
||||||
|
|
||||||
|
|
||||||
|
`priv` **`bool`**
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='set'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.runner.set(name, runner)
|
||||||
|
<a href="#set" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
*Sets* a runner by name. The difference between this function and
|
||||||
|
add, is set will *not* check if the named runner exists.
|
||||||
|
The runner table must have the run function in it.
|
||||||
|
#### Parameters
|
||||||
|
`name` **`string`**
|
||||||
|
|
||||||
|
|
||||||
|
`runner` **`table`**
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='setCurrent'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.runner.setCurrent(name)
|
||||||
|
<a href="#setCurrent" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Sets Hilbish's runner mode by name.
|
||||||
|
#### Parameters
|
||||||
|
`name` **`string`**
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='setMode'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.runner.setMode(mode)
|
||||||
|
<a href="#setMode" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
**NOTE: This function is deprecated and will be removed in 3.0**
|
||||||
|
Use `hilbish.runner.setCurrent` instead.
|
||||||
|
This is the same as the `hilbish.runnerMode` function.
|
||||||
|
It takes a callback, which will be used to execute all interactive input.
|
||||||
|
Or a string which names the runner mode to use.
|
||||||
|
#### Parameters
|
||||||
|
`mode` **`string|function`**
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='sh'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.runner.sh()
|
||||||
|
<a href="#sh" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
100
docs/api/hilbish/hilbish.timers.md
Normal file
100
docs/api/hilbish/hilbish.timers.md
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
---
|
||||||
|
title: Module hilbish.timers
|
||||||
|
description: timeout and interval API
|
||||||
|
layout: doc
|
||||||
|
menu:
|
||||||
|
docs:
|
||||||
|
parent: "API"
|
||||||
|
---
|
||||||
|
|
||||||
|
## Introduction
|
||||||
|
|
||||||
|
If you ever want to run a piece of code on a timed interval, or want to wait
|
||||||
|
a few seconds, you don't have to rely on timing tricks, as Hilbish has a
|
||||||
|
timer API to set intervals and timeouts.
|
||||||
|
|
||||||
|
These are the simple functions `hilbish.interval` and `hilbish.timeout` (doc
|
||||||
|
accessible with `doc hilbish`, or `Module hilbish` on the Website).
|
||||||
|
|
||||||
|
An example of usage:
|
||||||
|
```lua
|
||||||
|
local t = hilbish.timers.create(hilbish.timers.TIMEOUT, 5000, function()
|
||||||
|
print 'hello!'
|
||||||
|
end)
|
||||||
|
|
||||||
|
t:start()
|
||||||
|
print(t.running) // true
|
||||||
|
```
|
||||||
|
|
||||||
|
## Functions
|
||||||
|
|||
|
||||||
|
|----|----|
|
||||||
|
|<a href="#timers.create">create(type, time, callback) -> @Timer</a>|Creates a timer that runs based on the specified `time`.|
|
||||||
|
|<a href="#timers.get">get(id) -> @Timer</a>|Retrieves a timer via its ID.|
|
||||||
|
|
||||||
|
## Static module fields
|
||||||
|
|||
|
||||||
|
|----|----|
|
||||||
|
|INTERVAL|Constant for an interval timer type|
|
||||||
|
|TIMEOUT|Constant for a timeout timer type|
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='timers.create'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.timers.create(type, time, callback) -> <a href="/Hilbish/docs/api/hilbish/hilbish.timers/#timer" style="text-decoration: none;" id="lol">Timer</a>
|
||||||
|
<a href="#timers.create" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Creates a timer that runs based on the specified `time`.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
`number` **`type`**
|
||||||
|
What kind of timer to create, can either be `hilbish.timers.INTERVAL` or `hilbish.timers.TIMEOUT`
|
||||||
|
|
||||||
|
`number` **`time`**
|
||||||
|
The amount of time the function should run in milliseconds.
|
||||||
|
|
||||||
|
`function` **`callback`**
|
||||||
|
The function to run for the timer.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div id='timers.get'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.timers.get(id) -> <a href="/Hilbish/docs/api/hilbish/hilbish.timers/#timer" style="text-decoration: none;" id="lol">Timer</a>
|
||||||
|
<a href="#timers.get" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
Retrieves a timer via its ID.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
`number` **`id`**
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
## Types
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
## Timer
|
||||||
|
The Job type describes a Hilbish timer.
|
||||||
|
## Object properties
|
||||||
|
|||
|
||||||
|
|----|----|
|
||||||
|
|type|What type of timer it is|
|
||||||
|
|running|If the timer is running|
|
||||||
|
|duration|The duration in milliseconds that the timer will run|
|
||||||
|
|
||||||
|
|
||||||
|
### Methods
|
||||||
|
#### start()
|
||||||
|
Starts a timer.
|
||||||
|
|
||||||
|
#### stop()
|
||||||
|
Stops a timer.
|
||||||
|
|
20
docs/api/hilbish/hilbish.userDir.md
Normal file
20
docs/api/hilbish/hilbish.userDir.md
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
title: Module hilbish.userDir
|
||||||
|
description: user-related directories
|
||||||
|
layout: doc
|
||||||
|
menu:
|
||||||
|
docs:
|
||||||
|
parent: "API"
|
||||||
|
---
|
||||||
|
|
||||||
|
## Introduction
|
||||||
|
This interface just contains properties to know about certain user directories.
|
||||||
|
It is equivalent to XDG on Linux and gets the user's preferred directories
|
||||||
|
for configs and data.
|
||||||
|
|
||||||
|
## Static module fields
|
||||||
|
|||
|
||||||
|
|----|----|
|
||||||
|
|config|The user's config directory|
|
||||||
|
|data|The user's directory for program data|
|
||||||
|
|
@ -9,66 +9,42 @@ menu:
|
|||||||
|
|
||||||
## Introduction
|
## Introduction
|
||||||
|
|
||||||
|
|
||||||
The snail library houses Hilbish's Lua wrapper of its shell script interpreter.
|
The snail library houses Hilbish's Lua wrapper of its shell script interpreter.
|
||||||
It's not very useful other than running shell scripts, which can be done with other
|
It's not very useful other than running shell scripts, which can be done with other
|
||||||
Hilbish functions.
|
Hilbish functions.
|
||||||
|
|
||||||
## Functions
|
## Functions
|
||||||
|
|||
|
||||||
|
|----|----|
|
||||||
|
|<a href="#new">new() -> @Snail</a>|Creates a new Snail instance.|
|
||||||
|
|
||||||
``` =html
|
<hr>
|
||||||
<div class='relative overflow-x-auto sm:rounded-lg my-4'>
|
|
||||||
<table class='w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400'>
|
|
||||||
<tbody>
|
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'><a href="#new">new() -> @Snail</a></td>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Creates a new Snail instance.</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
```
|
|
||||||
|
|
||||||
## Functions
|
|
||||||
|
|
||||||
``` =html
|
|
||||||
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
|
|
||||||
<div id='new'>
|
<div id='new'>
|
||||||
<h4 class='text-xl font-medium mb-2'>
|
<h4 class='heading'>
|
||||||
snail.new() -> @Snail
|
snail.new() -> <a href="/Hilbish/docs/api/snail/#snail" style="text-decoration: none;" id="lol">Snail</a>
|
||||||
<a href="#new" class='heading-link'>
|
<a href="#new" class='heading-link'>
|
||||||
<i class="fas fa-paperclip"></i>
|
<i class="fas fa-paperclip"></i>
|
||||||
</a>
|
</a>
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
Creates a new Snail instance.
|
Creates a new Snail instance.
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
## Types
|
## Types
|
||||||
|
<hr>
|
||||||
``` =html
|
|
||||||
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
|
|
||||||
```
|
|
||||||
|
|
||||||
## Snail
|
## Snail
|
||||||
|
|
||||||
A Snail is a shell script interpreter instance.
|
A Snail is a shell script interpreter instance.
|
||||||
|
|
||||||
### Methods
|
### Methods
|
||||||
|
|
||||||
#### dir(path)
|
#### dir(path)
|
||||||
|
|
||||||
Changes the directory of the snail instance.
|
Changes the directory of the snail instance.
|
||||||
The interpreter keeps its set directory even when the Hilbish process changes
|
The interpreter keeps its set directory even when the Hilbish process changes
|
||||||
directory, so this should be called on the `hilbish.cd` hook.
|
directory, so this should be called on the `hilbish.cd` hook.
|
||||||
|
|
||||||
#### run(command, streams)
|
#### run(command, streams)
|
||||||
|
|
||||||
Runs a shell command. Works the same as `hilbish.run`, but only accepts a table of streams.
|
Runs a shell command. Works the same as `hilbish.run`, but only accepts a table of streams.
|
||||||
|
|
||||||
|
@ -8,112 +8,74 @@ menu:
|
|||||||
---
|
---
|
||||||
|
|
||||||
## Introduction
|
## Introduction
|
||||||
|
|
||||||
The terminal library is a simple and lower level library for certain terminal interactions.
|
The terminal library is a simple and lower level library for certain terminal interactions.
|
||||||
|
|
||||||
## Functions
|
## Functions
|
||||||
|
|||
|
||||||
|
|----|----|
|
||||||
|
|<a href="#restoreState">restoreState()</a>|Restores the last saved state of the terminal|
|
||||||
|
|<a href="#saveState">saveState()</a>|Saves the current state of the terminal.|
|
||||||
|
|<a href="#setRaw">setRaw()</a>|Puts the terminal into raw mode.|
|
||||||
|
|<a href="#size">size()</a>|Gets the dimensions of the terminal. Returns a table with `width` and `height`|
|
||||||
|
|
||||||
``` =html
|
<hr>
|
||||||
<div class='relative overflow-x-auto sm:rounded-lg my-4'>
|
|
||||||
<table class='w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400'>
|
|
||||||
<tbody>
|
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'><a href="#restoreState">restoreState()</a></td>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Restores the last saved state of the terminal</td>
|
|
||||||
</tr>
|
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'><a href="#saveState">saveState()</a></td>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Saves the current state of the terminal.</td>
|
|
||||||
</tr>
|
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'><a href="#setRaw">setRaw()</a></td>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Puts the terminal into raw mode.</td>
|
|
||||||
</tr>
|
|
||||||
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'><a href="#size">size()</a></td>
|
|
||||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Gets the dimensions of the terminal. Returns a table with `width` and `height`</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
```
|
|
||||||
|
|
||||||
## Functions
|
|
||||||
|
|
||||||
``` =html
|
|
||||||
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
|
|
||||||
<div id='restoreState'>
|
<div id='restoreState'>
|
||||||
<h4 class='text-xl font-medium mb-2'>
|
<h4 class='heading'>
|
||||||
terminal.restoreState()
|
terminal.restoreState()
|
||||||
<a href="#restoreState" class='heading-link'>
|
<a href="#restoreState" class='heading-link'>
|
||||||
<i class="fas fa-paperclip"></i>
|
<i class="fas fa-paperclip"></i>
|
||||||
</a>
|
</a>
|
||||||
</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>
|
||||||
|
|
||||||
|
<hr>
|
||||||
``` =html
|
|
||||||
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
|
|
||||||
<div id='saveState'>
|
<div id='saveState'>
|
||||||
<h4 class='text-xl font-medium mb-2'>
|
<h4 class='heading'>
|
||||||
terminal.saveState()
|
terminal.saveState()
|
||||||
<a href="#saveState" class='heading-link'>
|
<a href="#saveState" class='heading-link'>
|
||||||
<i class="fas fa-paperclip"></i>
|
<i class="fas fa-paperclip"></i>
|
||||||
</a>
|
</a>
|
||||||
</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>
|
||||||
|
|
||||||
|
<hr>
|
||||||
``` =html
|
|
||||||
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
|
|
||||||
<div id='setRaw'>
|
<div id='setRaw'>
|
||||||
<h4 class='text-xl font-medium mb-2'>
|
<h4 class='heading'>
|
||||||
terminal.setRaw()
|
terminal.setRaw()
|
||||||
<a href="#setRaw" class='heading-link'>
|
<a href="#setRaw" class='heading-link'>
|
||||||
<i class="fas fa-paperclip"></i>
|
<i class="fas fa-paperclip"></i>
|
||||||
</a>
|
</a>
|
||||||
</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>
|
||||||
|
|
||||||
|
<hr>
|
||||||
``` =html
|
|
||||||
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
|
|
||||||
<div id='size'>
|
<div id='size'>
|
||||||
<h4 class='text-xl font-medium mb-2'>
|
<h4 class='heading'>
|
||||||
terminal.size()
|
terminal.size()
|
||||||
<a href="#size" class='heading-link'>
|
<a href="#size" class='heading-link'>
|
||||||
<i class="fas fa-paperclip"></i>
|
<i class="fas fa-paperclip"></i>
|
||||||
</a>
|
</a>
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
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>
|
||||||
|
|
||||||
|
28
emmyLuaDocs/bait.lua
Normal file
28
emmyLuaDocs/bait.lua
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
--- @meta
|
||||||
|
|
||||||
|
local bait = {}
|
||||||
|
|
||||||
|
--- Catches an event. This function can be used to act on events.
|
||||||
|
---
|
||||||
|
---
|
||||||
|
function bait.catch(name, cb) end
|
||||||
|
|
||||||
|
--- Catches an event, but only once. This will remove the hook immediately after it runs for the first time.
|
||||||
|
function bait.catchOnce(name, cb) end
|
||||||
|
|
||||||
|
--- Returns a table of functions that are hooked on an event with the corresponding `name`.
|
||||||
|
function bait.hooks(name) end
|
||||||
|
|
||||||
|
--- Removes the `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.
|
||||||
|
---
|
||||||
|
---
|
||||||
|
function bait.release(name, catcher) end
|
||||||
|
|
||||||
|
--- Throws a hook with `name` with the provided `args`.
|
||||||
|
---
|
||||||
|
---
|
||||||
|
function bait.throw(name, ...args) end
|
||||||
|
|
||||||
|
return bait
|
18
emmyLuaDocs/commander.lua
Normal file
18
emmyLuaDocs/commander.lua
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
--- @meta
|
||||||
|
|
||||||
|
local commander = {}
|
||||||
|
|
||||||
|
--- Removes the named command. Note that this will only remove Commander-registered commands.
|
||||||
|
function commander.deregister(name) end
|
||||||
|
|
||||||
|
--- 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.
|
||||||
|
---
|
||||||
|
---
|
||||||
|
function commander.register(name, cb) end
|
||||||
|
|
||||||
|
--- Returns all registered commanders. Returns a list of tables with the following keys:
|
||||||
|
--- - `exec`: The function used to run the commander. Commanders require args and sinks to be passed.
|
||||||
|
function commander.registry() end
|
||||||
|
|
||||||
|
return commander
|
54
emmyLuaDocs/fs.lua
Normal file
54
emmyLuaDocs/fs.lua
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
--- @meta
|
||||||
|
|
||||||
|
local fs = {}
|
||||||
|
|
||||||
|
--- Returns an absolute version of the `path`.
|
||||||
|
--- This can be used to resolve short paths like `..` to `/home/user`.
|
||||||
|
function fs.abs(path) end
|
||||||
|
|
||||||
|
--- Returns the "basename," or the last part of the provided `path`. If path is empty,
|
||||||
|
--- `.` will be returned.
|
||||||
|
function fs.basename(path) end
|
||||||
|
|
||||||
|
--- Changes Hilbish's directory to `dir`.
|
||||||
|
function fs.cd(dir) end
|
||||||
|
|
||||||
|
--- Returns the directory part of `path`. If a file path like
|
||||||
|
--- `~/Documents/doc.txt` then this function will return `~/Documents`.
|
||||||
|
function fs.dir(path) end
|
||||||
|
|
||||||
|
--- 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
|
||||||
|
---
|
||||||
|
---
|
||||||
|
function fs.glob(pattern) end
|
||||||
|
|
||||||
|
--- Takes any list of paths and joins them based on the operating system's path separator.
|
||||||
|
---
|
||||||
|
---
|
||||||
|
function fs.join(...path) end
|
||||||
|
|
||||||
|
--- Creates a new directory with the provided `name`.
|
||||||
|
--- With `recursive`, mkdir will create parent directories.
|
||||||
|
---
|
||||||
|
---
|
||||||
|
function fs.mkdir(name, recursive) end
|
||||||
|
|
||||||
|
--- Returns a pair of connected files, also known as a pipe.
|
||||||
|
--- The type returned is a Lua file, same as returned from `io` functions.
|
||||||
|
function fs.fpipe() end
|
||||||
|
|
||||||
|
--- Returns a list of all files and directories in the provided path.
|
||||||
|
function fs.readdir(path) end
|
||||||
|
|
||||||
|
--- Returns the information about a given `path`.
|
||||||
|
--- 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
|
||||||
|
---
|
||||||
|
---
|
||||||
|
function fs.stat(path) end
|
||||||
|
|
||||||
|
return fs
|
240
emmyLuaDocs/hilbish.lua
Normal file
240
emmyLuaDocs/hilbish.lua
Normal file
@ -0,0 +1,240 @@
|
|||||||
|
--- @meta
|
||||||
|
|
||||||
|
local hilbish = {}
|
||||||
|
|
||||||
|
--- Sets/toggles the option of automatically flushing output.
|
||||||
|
--- A call with no argument will toggle the value.
|
||||||
|
--- @param auto boolean|nil
|
||||||
|
function hilbish:autoFlush(auto) end
|
||||||
|
|
||||||
|
--- Flush writes all buffered input to the sink.
|
||||||
|
function hilbish:flush() end
|
||||||
|
|
||||||
|
--- Reads a liine of input from the sink.
|
||||||
|
--- @returns string
|
||||||
|
function hilbish:read() end
|
||||||
|
|
||||||
|
--- Reads all input from the sink.
|
||||||
|
--- @returns string
|
||||||
|
function hilbish:readAll() end
|
||||||
|
|
||||||
|
--- Writes data to a sink.
|
||||||
|
function hilbish:write(str) end
|
||||||
|
|
||||||
|
--- Writes data to a sink with a newline at the end.
|
||||||
|
function hilbish:writeln(str) end
|
||||||
|
|
||||||
|
--- This is an alias (ha) for the [hilbish.alias](../#alias) function.
|
||||||
|
--- @param alias string
|
||||||
|
--- @param cmd string
|
||||||
|
function hilbish.aliases.add(alias, cmd) end
|
||||||
|
|
||||||
|
--- Deletes characters in the line by the given amount.
|
||||||
|
function hilbish.editor.deleteByAmount(amount) end
|
||||||
|
|
||||||
|
--- Returns the current input line.
|
||||||
|
function hilbish.editor.getLine() end
|
||||||
|
|
||||||
|
--- Returns the text that is at the register.
|
||||||
|
function hilbish.editor.getVimRegister(register) end
|
||||||
|
|
||||||
|
--- Inserts text into the Hilbish command line.
|
||||||
|
function hilbish.editor.insert(text) end
|
||||||
|
|
||||||
|
--- Reads a keystroke from the user. This is in a format of something like Ctrl-L.
|
||||||
|
function hilbish.editor.getChar() end
|
||||||
|
|
||||||
|
--- Sets the vim register at `register` to hold the passed text.
|
||||||
|
function hilbish.editor.setVimRegister(register, text) end
|
||||||
|
|
||||||
|
--- Return binaries/executables based on the provided parameters.
|
||||||
|
--- This function is meant to be used as a helper in a command completion handler.
|
||||||
|
---
|
||||||
|
---
|
||||||
|
function hilbish.completion.bins(query, ctx, fields) end
|
||||||
|
|
||||||
|
--- 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`.
|
||||||
|
--- You can check the Completions doc or `doc completions` for info on the `completionGroups` return value.
|
||||||
|
function hilbish.completion.call(name, query, ctx, fields) end
|
||||||
|
|
||||||
|
--- Returns file matches based on the provided parameters.
|
||||||
|
--- This function is meant to be used as a helper in a command completion handler.
|
||||||
|
function hilbish.completion.files(query, ctx, fields) end
|
||||||
|
|
||||||
|
--- This function contains the general completion handler for Hilbish. This function handles
|
||||||
|
--- 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.
|
||||||
|
---
|
||||||
|
---
|
||||||
|
function hilbish.completion.handler(line, pos) end
|
||||||
|
|
||||||
|
--- Sets an alias, with a name of `cmd` to another command.
|
||||||
|
---
|
||||||
|
---
|
||||||
|
function hilbish.alias(cmd, orig) end
|
||||||
|
|
||||||
|
--- Appends the provided dir to the command path (`$PATH`)
|
||||||
|
---
|
||||||
|
---
|
||||||
|
function hilbish.appendPath(dir) end
|
||||||
|
|
||||||
|
--- Registers a completion handler for the specified scope.
|
||||||
|
--- 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.
|
||||||
|
---
|
||||||
|
---
|
||||||
|
function hilbish.complete(scope, cb) end
|
||||||
|
|
||||||
|
--- Returns the current directory of the shell.
|
||||||
|
function hilbish.cwd() end
|
||||||
|
|
||||||
|
--- Replaces the currently running Hilbish instance with the supplied command.
|
||||||
|
--- This can be used to do an in-place restart.
|
||||||
|
function hilbish.exec(cmd) end
|
||||||
|
|
||||||
|
--- 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.**
|
||||||
|
function hilbish.goro(fn) end
|
||||||
|
|
||||||
|
--- Line highlighter handler.
|
||||||
|
--- 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.
|
||||||
|
---
|
||||||
|
function hilbish.highlighter(line) end
|
||||||
|
|
||||||
|
--- The command line hint handler. It gets called on every key insert to
|
||||||
|
--- 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.
|
||||||
|
---
|
||||||
|
---
|
||||||
|
function hilbish.hinter(line, pos) end
|
||||||
|
|
||||||
|
--- 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.
|
||||||
|
function hilbish.inputMode(mode) end
|
||||||
|
|
||||||
|
--- Runs the `cb` function every specified amount of `time`.
|
||||||
|
--- This creates a timer that ticking immediately.
|
||||||
|
function hilbish.interval(cb, time) end
|
||||||
|
|
||||||
|
--- Changes the text prompt when Hilbish asks for more input.
|
||||||
|
--- This will show up when text is incomplete, like a missing quote
|
||||||
|
---
|
||||||
|
---
|
||||||
|
function hilbish.multiprompt(str) end
|
||||||
|
|
||||||
|
--- Prepends `dir` to $PATH.
|
||||||
|
function hilbish.prependPath(dir) end
|
||||||
|
|
||||||
|
--- Changes the shell prompt to the provided string.
|
||||||
|
--- 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
|
||||||
|
---
|
||||||
|
function hilbish.prompt(str, typ) end
|
||||||
|
|
||||||
|
--- 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.
|
||||||
|
function hilbish.read(prompt) end
|
||||||
|
|
||||||
|
--- Executed the `cb` function after a period of `time`.
|
||||||
|
--- This creates a Timer that starts ticking immediately.
|
||||||
|
function hilbish.timeout(cb, time) end
|
||||||
|
|
||||||
|
--- Checks if `name` is a valid command.
|
||||||
|
--- Will return the path of the binary, or a basename if it's a commander.
|
||||||
|
function hilbish.which(name) end
|
||||||
|
|
||||||
|
--- Puts a job in the background. This acts the same as initially running a job.
|
||||||
|
function hilbish.jobs:background() end
|
||||||
|
|
||||||
|
--- Puts a job in the foreground. This will cause it to run like it was
|
||||||
|
--- executed normally and wait for it to complete.
|
||||||
|
function hilbish.jobs:foreground() end
|
||||||
|
|
||||||
|
--- Evaluates `cmd` as Lua input. This is the same as using `dofile`
|
||||||
|
--- or `load`, but is appropriated for the runner interface.
|
||||||
|
function hilbish.runner.lua(cmd) end
|
||||||
|
|
||||||
|
--- Starts running the job.
|
||||||
|
function hilbish.jobs:start() end
|
||||||
|
|
||||||
|
--- Stops the job from running.
|
||||||
|
function hilbish.jobs:stop() end
|
||||||
|
|
||||||
|
--- Loads a module at the designated `path`.
|
||||||
|
--- It will throw if any error occurs.
|
||||||
|
function hilbish.module.load(path) end
|
||||||
|
|
||||||
|
--- Starts a timer.
|
||||||
|
function hilbish.timers:start() end
|
||||||
|
|
||||||
|
--- Stops a timer.
|
||||||
|
function hilbish.timers:stop() end
|
||||||
|
|
||||||
|
--- Removes an alias.
|
||||||
|
function hilbish.aliases.delete(name) end
|
||||||
|
|
||||||
|
--- Get a table of all aliases, with string keys as the alias and the value as the command.
|
||||||
|
---
|
||||||
|
---
|
||||||
|
function hilbish.aliases.list() end
|
||||||
|
|
||||||
|
--- Resolves an alias to its original command. Will thrown an error if the alias doesn't exist.
|
||||||
|
function hilbish.aliases.resolve(alias) end
|
||||||
|
|
||||||
|
--- 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.
|
||||||
|
---
|
||||||
|
---
|
||||||
|
function hilbish.jobs.add(cmdstr, args, execPath) end
|
||||||
|
|
||||||
|
--- Returns a table of all job objects.
|
||||||
|
function hilbish.jobs.all() end
|
||||||
|
|
||||||
|
--- Disowns a job. This simply deletes it from the list of jobs without stopping it.
|
||||||
|
function hilbish.jobs.disown(id) end
|
||||||
|
|
||||||
|
--- Get a job object via its ID.
|
||||||
|
--- @param id number
|
||||||
|
--- @returns Job
|
||||||
|
function hilbish.jobs.get(id) end
|
||||||
|
|
||||||
|
--- Returns the last added job to the table.
|
||||||
|
function hilbish.jobs.last() end
|
||||||
|
|
||||||
|
--- Adds a command to the history.
|
||||||
|
function hilbish.history.add(cmd) end
|
||||||
|
|
||||||
|
--- Retrieves all history as a table.
|
||||||
|
function hilbish.history.all() end
|
||||||
|
|
||||||
|
--- Deletes all commands from the history.
|
||||||
|
function hilbish.history.clear() end
|
||||||
|
|
||||||
|
--- Retrieves a command from the history based on the `index`.
|
||||||
|
function hilbish.history.get(index) end
|
||||||
|
|
||||||
|
--- Returns the amount of commands in the history.
|
||||||
|
function hilbish.history.size() end
|
||||||
|
|
||||||
|
--- Creates a timer that runs based on the specified `time`.
|
||||||
|
function hilbish.timers.create(type, time, callback) end
|
||||||
|
|
||||||
|
--- Retrieves a timer via its ID.
|
||||||
|
function hilbish.timers.get(id) end
|
||||||
|
|
||||||
|
return hilbish
|
16
emmyLuaDocs/snail.lua
Normal file
16
emmyLuaDocs/snail.lua
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
--- @meta
|
||||||
|
|
||||||
|
local snail = {}
|
||||||
|
|
||||||
|
--- Changes the directory of the snail instance.
|
||||||
|
--- The interpreter keeps its set directory even when the Hilbish process changes
|
||||||
|
--- directory, so this should be called on the `hilbish.cd` hook.
|
||||||
|
function snail:dir(path) end
|
||||||
|
|
||||||
|
--- Creates a new Snail instance.
|
||||||
|
function snail.new() end
|
||||||
|
|
||||||
|
--- Runs a shell command. Works the same as `hilbish.run`, but only accepts a table of streams.
|
||||||
|
function snail:run(command, streams) end
|
||||||
|
|
||||||
|
return snail
|
18
emmyLuaDocs/terminal.lua
Normal file
18
emmyLuaDocs/terminal.lua
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
--- @meta
|
||||||
|
|
||||||
|
local terminal = {}
|
||||||
|
|
||||||
|
--- Restores the last saved state of the terminal
|
||||||
|
function terminal.restoreState() end
|
||||||
|
|
||||||
|
--- Saves the current state of the terminal.
|
||||||
|
function terminal.saveState() end
|
||||||
|
|
||||||
|
--- Puts the terminal into raw mode.
|
||||||
|
function terminal.setRaw() end
|
||||||
|
|
||||||
|
--- 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.
|
||||||
|
function terminal.size() end
|
||||||
|
|
||||||
|
return terminal
|
83
emmyLuaDocs/util.lua
Normal file
83
emmyLuaDocs/util.lua
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
--- @meta
|
||||||
|
|
||||||
|
local util = {}
|
||||||
|
|
||||||
|
---
|
||||||
|
function util.AbbrevHome changes the user's home directory in the path string to ~ (tilde) end
|
||||||
|
|
||||||
|
---
|
||||||
|
function util. end
|
||||||
|
|
||||||
|
---
|
||||||
|
function util.DoFile runs the contents of the file in the Lua runtime. end
|
||||||
|
|
||||||
|
---
|
||||||
|
function util.DoString runs the code string in the Lua runtime. end
|
||||||
|
|
||||||
|
--- directory.
|
||||||
|
function util.ExpandHome expands ~ (tilde) in the path, changing it to the user home end
|
||||||
|
|
||||||
|
---
|
||||||
|
function util. end
|
||||||
|
|
||||||
|
---
|
||||||
|
function util.ForEach loops through a Lua table. end
|
||||||
|
|
||||||
|
---
|
||||||
|
function util. end
|
||||||
|
|
||||||
|
--- a string and a closure.
|
||||||
|
function util.HandleStrCallback handles function parameters for Go functions which take end
|
||||||
|
|
||||||
|
---
|
||||||
|
function util. end
|
||||||
|
|
||||||
|
---
|
||||||
|
function util. end
|
||||||
|
|
||||||
|
---
|
||||||
|
function util.SetExports puts the Lua function exports in the table. end
|
||||||
|
|
||||||
|
--- It is accessible via the __docProp metatable. It is a table of the names of the fields.
|
||||||
|
function util.SetField sets a field in a table, adding docs for it. end
|
||||||
|
|
||||||
|
--- is one which has a metatable proxy to ensure no overrides happen to it.
|
||||||
|
--- It sets the field in the table and sets the __docProp metatable on the
|
||||||
|
--- user facing table.
|
||||||
|
function util.SetFieldProtected sets a field in a protected table. A protected table end
|
||||||
|
|
||||||
|
--- Sets/toggles the option of automatically flushing output.
|
||||||
|
--- A call with no argument will toggle the value.
|
||||||
|
--- @param auto boolean|nil
|
||||||
|
function util:autoFlush(auto) end
|
||||||
|
|
||||||
|
--- Flush writes all buffered input to the sink.
|
||||||
|
function util:flush() end
|
||||||
|
|
||||||
|
---
|
||||||
|
function util. end
|
||||||
|
|
||||||
|
--- Reads a liine of input from the sink.
|
||||||
|
--- @returns string
|
||||||
|
function util:read() end
|
||||||
|
|
||||||
|
--- Reads all input from the sink.
|
||||||
|
--- @returns string
|
||||||
|
function util:readAll() end
|
||||||
|
|
||||||
|
--- Writes data to a sink.
|
||||||
|
function util:write(str) end
|
||||||
|
|
||||||
|
--- Writes data to a sink with a newline at the end.
|
||||||
|
function util:writeln(str) end
|
||||||
|
|
||||||
|
---
|
||||||
|
function util. end
|
||||||
|
|
||||||
|
---
|
||||||
|
function util. end
|
||||||
|
|
||||||
|
---
|
||||||
|
function util. end
|
||||||
|
|
||||||
|
return util
|
@ -5,45 +5,56 @@ layout: page
|
|||||||
---
|
---
|
||||||
|
|
||||||
## Official Binaries
|
## Official Binaries
|
||||||
|
|
||||||
The best way to get Hilbish is to get a build directly from GitHub.
|
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:
|
||||||
At any time, there are 2 versions of Hilbish available to install:
|
|
||||||
the latest stable release, and development builds from the master branch.
|
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
|
You can download both at any time, but note that the development builds may
|
||||||
have breaking changes.
|
have breaking changes.
|
||||||
|
|
||||||
For the latest *stable release*, check here: https://github.com/Rosettea/Hilbish/releases/latest
|
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
|
||||||
For a *development build*: https://nightly.link/Rosettea/Hilbish/workflows/build/master
|
|
||||||
|
|
||||||
## Compiling
|
## Compiling
|
||||||
|
|
||||||
To read the steps for compiling Hilbish, head over to the [GitHub repository.](https://github.com/Rosettea/Hilbish#build)
|
To read the steps for compiling Hilbish, head over to the [GitHub repository.](https://github.com/Rosettea/Hilbish#build)
|
||||||
|
|
||||||
## Package Repositories
|
## Package Repositories
|
||||||
|
|
||||||
Methods of installing Hilbish for your Linux distro.
|
Methods of installing Hilbish for your Linux distro.
|
||||||
|
|
||||||
### Fedora (COPR)
|
### Fedora (COPR)
|
||||||
|
|
||||||
An official COPR is offered to install Hilbish easily on Fedora.
|
An official COPR is offered to install Hilbish easily on Fedora.
|
||||||
Enable the repo: `dnf copr enable sammyette/Hilbish`
|
Enable the repo:
|
||||||
|
```
|
||||||
|
sudo dnf copr enable sammyette/Hilbish
|
||||||
|
```
|
||||||
|
|
||||||
And install Hilbish: `dnf install hilbish`
|
And install Hilbish:
|
||||||
|
```
|
||||||
|
sudo dnf install hilbish
|
||||||
|
```
|
||||||
|
|
||||||
Or for the latest development build from master: `dnf install hilbish-git`
|
Or for the latest development build from master:
|
||||||
|
```
|
||||||
|
sudo dnf install hilbish-git
|
||||||
|
```
|
||||||
|
|
||||||
### Arch Linux (AUR)
|
### Arch Linux (AUR)
|
||||||
|
|
||||||
Hilbish is on the AUR. Setup an AUR helper, and install.
|
Hilbish is on the AUR. Setup an AUR helper, and install.
|
||||||
|
Example with yay:
|
||||||
|
|
||||||
Example with yay: `yay -S hilbish`
|
```
|
||||||
|
yay -S hilbish
|
||||||
|
```
|
||||||
|
|
||||||
Or, from master branch: `yay -S hilbish-git`
|
Or, from master branch:
|
||||||
|
```
|
||||||
|
yay -S hilbish-git
|
||||||
|
```
|
||||||
|
|
||||||
### Alpine Linux
|
### Alpine Linux
|
||||||
|
|
||||||
Hilbish is currentlty in the testing/edge repository for Alpine.
|
Hilbish is currentlty in the testing/edge repository for Alpine.
|
||||||
Follow the steps [here](https://wiki.alpinelinux.org/wiki/Enable_Community_Repository) (using testing repositories) and install: `apk add hilbish`
|
Follow the steps [here](https://wiki.alpinelinux.org/wiki/Enable_Community_Repository)
|
||||||
|
(Using testing repositories) and install:
|
||||||
|
```
|
||||||
|
apk add hilbish
|
||||||
|
```
|
||||||
|
@ -19,6 +19,7 @@ lustre_ssg = { git = "https://github.com/lustre-labs/ssg.git", ref = "v0.11.0" }
|
|||||||
tom = ">= 1.1.1 and < 2.0.0"
|
tom = ">= 1.1.1 and < 2.0.0"
|
||||||
simplifile = ">= 2.2.1 and < 3.0.0"
|
simplifile = ">= 2.2.1 and < 3.0.0"
|
||||||
glaml = ">= 3.0.2 and < 4.0.0"
|
glaml = ">= 3.0.2 and < 4.0.0"
|
||||||
|
mdex = ">= 0.6.1 and < 1.0.0"
|
||||||
jot = ">= 4.0.0 and < 5.0.0"
|
jot = ">= 4.0.0 and < 5.0.0"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
packages = [
|
packages = [
|
||||||
{ name = "argv", version = "1.0.2", build_tools = ["gleam"], requirements = [], otp_app = "argv", source = "hex", outer_checksum = "BA1FF0929525DEBA1CE67256E5ADF77A7CDDFE729E3E3F57A5BDCAA031DED09D" },
|
{ name = "argv", version = "1.0.2", build_tools = ["gleam"], requirements = [], otp_app = "argv", source = "hex", outer_checksum = "BA1FF0929525DEBA1CE67256E5ADF77A7CDDFE729E3E3F57A5BDCAA031DED09D" },
|
||||||
|
{ name = "autumn", version = "0.3.2", build_tools = ["mix"], requirements = ["nimble_options", "rustler", "rustler_precompiled"], otp_app = "autumn", source = "hex", outer_checksum = "5C8C4A30F3159E7C63C7A3F97D274EC9693402AA30EEDE855870DB7F390DEB67" },
|
||||||
|
{ name = "castore", version = "1.0.12", build_tools = ["mix"], requirements = [], otp_app = "castore", source = "hex", outer_checksum = "3DCA286B2186055BA0C9449B4E95B97BF1B57B47C1F2644555879E659960C224" },
|
||||||
{ name = "directories", version = "1.2.0", build_tools = ["gleam"], requirements = ["envoy", "gleam_stdlib", "platform", "simplifile"], otp_app = "directories", source = "hex", outer_checksum = "D13090CFCDF6759B87217E8DDD73A75903A700148A82C1D33799F333E249BF9E" },
|
{ name = "directories", version = "1.2.0", build_tools = ["gleam"], requirements = ["envoy", "gleam_stdlib", "platform", "simplifile"], otp_app = "directories", source = "hex", outer_checksum = "D13090CFCDF6759B87217E8DDD73A75903A700148A82C1D33799F333E249BF9E" },
|
||||||
{ name = "envoy", version = "1.0.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "envoy", source = "hex", outer_checksum = "95FD059345AA982E89A0B6E2A3BF1CF43E17A7048DCD85B5B65D3B9E4E39D359" },
|
{ name = "envoy", version = "1.0.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "envoy", source = "hex", outer_checksum = "95FD059345AA982E89A0B6E2A3BF1CF43E17A7048DCD85B5B65D3B9E4E39D359" },
|
||||||
{ name = "exception", version = "2.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "exception", source = "hex", outer_checksum = "F5580D584F16A20B7FCDCABF9E9BE9A2C1F6AC4F9176FA6DD0B63E3B20D450AA" },
|
{ name = "exception", version = "2.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "exception", source = "hex", outer_checksum = "F5580D584F16A20B7FCDCABF9E9BE9A2C1F6AC4F9176FA6DD0B63E3B20D450AA" },
|
||||||
@ -28,15 +30,20 @@ packages = [
|
|||||||
{ name = "gramps", version = "3.0.1", build_tools = ["gleam"], requirements = ["gleam_crypto", "gleam_erlang", "gleam_http", "gleam_stdlib"], otp_app = "gramps", source = "hex", outer_checksum = "59194B3980110B403EE6B75330DB82CDE05FC8138491C2EAEACBC7AAEF30B2E8" },
|
{ name = "gramps", version = "3.0.1", build_tools = ["gleam"], requirements = ["gleam_crypto", "gleam_erlang", "gleam_http", "gleam_stdlib"], otp_app = "gramps", source = "hex", outer_checksum = "59194B3980110B403EE6B75330DB82CDE05FC8138491C2EAEACBC7AAEF30B2E8" },
|
||||||
{ name = "houdini", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "houdini", source = "hex", outer_checksum = "5BA517E5179F132F0471CB314F27FE210A10407387DA1EA4F6FD084F74469FC2" },
|
{ name = "houdini", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "houdini", source = "hex", outer_checksum = "5BA517E5179F132F0471CB314F27FE210A10407387DA1EA4F6FD084F74469FC2" },
|
||||||
{ name = "hpack_erl", version = "0.3.0", build_tools = ["rebar3"], requirements = [], otp_app = "hpack", source = "hex", outer_checksum = "D6137D7079169D8C485C6962DFE261AF5B9EF60FBC557344511C1E65E3D95FB0" },
|
{ name = "hpack_erl", version = "0.3.0", build_tools = ["rebar3"], requirements = [], otp_app = "hpack", source = "hex", outer_checksum = "D6137D7079169D8C485C6962DFE261AF5B9EF60FBC557344511C1E65E3D95FB0" },
|
||||||
|
{ name = "jason", version = "1.4.4", build_tools = ["mix"], requirements = ["decimal"], otp_app = "jason", source = "hex", outer_checksum = "C5EB0CAB91F094599F94D55BC63409236A8EC69A21A67814529E8D5F6CC90B3B" },
|
||||||
{ name = "jot", version = "4.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "houdini", "splitter"], otp_app = "jot", source = "hex", outer_checksum = "E9E266D2768EA1238283D2CF125AA68095F17BAA4DDF3598360FD19F38593C59" },
|
{ name = "jot", version = "4.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "houdini", "splitter"], otp_app = "jot", source = "hex", outer_checksum = "E9E266D2768EA1238283D2CF125AA68095F17BAA4DDF3598360FD19F38593C59" },
|
||||||
{ name = "logging", version = "1.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "logging", source = "hex", outer_checksum = "1098FBF10B54B44C2C7FDF0B01C1253CAFACDACABEFB4B0D027803246753E06D" },
|
{ name = "logging", version = "1.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "logging", source = "hex", outer_checksum = "1098FBF10B54B44C2C7FDF0B01C1253CAFACDACABEFB4B0D027803246753E06D" },
|
||||||
{ name = "lustre", version = "5.0.2", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_json", "gleam_otp", "gleam_stdlib", "houdini"], otp_app = "lustre", source = "hex", outer_checksum = "ED46F0CA5BA61067DDC2CEDEA9906AC99E88F49918EFDC58283A531F0A14F042" },
|
{ name = "lustre", version = "5.0.2", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_json", "gleam_otp", "gleam_stdlib", "houdini"], otp_app = "lustre", source = "hex", outer_checksum = "ED46F0CA5BA61067DDC2CEDEA9906AC99E88F49918EFDC58283A531F0A14F042" },
|
||||||
{ name = "lustre_dev_tools", version = "1.7.1", build_tools = ["gleam"], requirements = ["argv", "filepath", "fs", "gleam_community_ansi", "gleam_crypto", "gleam_deque", "gleam_erlang", "gleam_http", "gleam_httpc", "gleam_json", "gleam_otp", "gleam_package_interface", "gleam_regexp", "gleam_stdlib", "glint", "glisten", "lustre", "mist", "repeatedly", "simplifile", "term_size", "tom", "wisp"], otp_app = "lustre_dev_tools", source = "hex", outer_checksum = "B426F3E518B44144643CAE956D072E3ADAA9BBC71ECE08CD559CA0276A74C167" },
|
{ name = "lustre_dev_tools", version = "1.7.1", build_tools = ["gleam"], requirements = ["argv", "filepath", "fs", "gleam_community_ansi", "gleam_crypto", "gleam_deque", "gleam_erlang", "gleam_http", "gleam_httpc", "gleam_json", "gleam_otp", "gleam_package_interface", "gleam_regexp", "gleam_stdlib", "glint", "glisten", "lustre", "mist", "repeatedly", "simplifile", "term_size", "tom", "wisp"], otp_app = "lustre_dev_tools", source = "hex", outer_checksum = "B426F3E518B44144643CAE956D072E3ADAA9BBC71ECE08CD559CA0276A74C167" },
|
||||||
{ name = "lustre_ssg", version = "0.11.0", build_tools = ["gleam"], requirements = ["filepath", "gleam_regexp", "gleam_stdlib", "jot", "lustre", "simplifile", "temporary", "tom"], source = "git", repo = "https://github.com/lustre-labs/ssg.git", commit = "3b75ef77a5038b4843a0f8b18f31331d0d64a543" },
|
{ name = "lustre_ssg", version = "0.11.0", build_tools = ["gleam"], requirements = ["filepath", "gleam_regexp", "gleam_stdlib", "jot", "lustre", "simplifile", "temporary", "tom"], source = "git", repo = "https://github.com/lustre-labs/ssg.git", commit = "3b75ef77a5038b4843a0f8b18f31331d0d64a543" },
|
||||||
{ name = "marceau", version = "1.3.0", build_tools = ["gleam"], requirements = [], otp_app = "marceau", source = "hex", outer_checksum = "2D1C27504BEF45005F5DFB18591F8610FB4BFA91744878210BDC464412EC44E9" },
|
{ name = "marceau", version = "1.3.0", build_tools = ["gleam"], requirements = [], otp_app = "marceau", source = "hex", outer_checksum = "2D1C27504BEF45005F5DFB18591F8610FB4BFA91744878210BDC464412EC44E9" },
|
||||||
|
{ name = "mdex", version = "0.6.1", build_tools = ["mix"], requirements = ["autumn", "jason", "nimble_options", "rustler", "rustler_precompiled"], otp_app = "mdex", source = "hex", outer_checksum = "025645518F19E585878AE2D4210BD5C78A92010169006AA3C5CD9C758F982F37" },
|
||||||
{ name = "mist", version = "4.0.7", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_http", "gleam_otp", "gleam_stdlib", "gleam_yielder", "glisten", "gramps", "hpack_erl", "logging"], otp_app = "mist", source = "hex", outer_checksum = "F7D15A1E3232E124C7CE31900253633434E59B34ED0E99F273DEE61CDB573CDD" },
|
{ name = "mist", version = "4.0.7", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_http", "gleam_otp", "gleam_stdlib", "gleam_yielder", "glisten", "gramps", "hpack_erl", "logging"], otp_app = "mist", source = "hex", outer_checksum = "F7D15A1E3232E124C7CE31900253633434E59B34ED0E99F273DEE61CDB573CDD" },
|
||||||
|
{ name = "nimble_options", version = "1.1.1", build_tools = ["mix"], requirements = [], otp_app = "nimble_options", source = "hex", outer_checksum = "821B2470CA9442C4B6984882FE9BB0389371B8DDEC4D45A9504F00A66F650B44" },
|
||||||
{ name = "platform", version = "1.0.0", build_tools = ["gleam"], requirements = [], otp_app = "platform", source = "hex", outer_checksum = "8339420A95AD89AAC0F82F4C3DB8DD401041742D6C3F46132A8739F6AEB75391" },
|
{ name = "platform", version = "1.0.0", build_tools = ["gleam"], requirements = [], otp_app = "platform", source = "hex", outer_checksum = "8339420A95AD89AAC0F82F4C3DB8DD401041742D6C3F46132A8739F6AEB75391" },
|
||||||
{ name = "repeatedly", version = "2.1.2", build_tools = ["gleam"], requirements = [], otp_app = "repeatedly", source = "hex", outer_checksum = "93AE1938DDE0DC0F7034F32C1BF0D4E89ACEBA82198A1FE21F604E849DA5F589" },
|
{ name = "repeatedly", version = "2.1.2", build_tools = ["gleam"], requirements = [], otp_app = "repeatedly", source = "hex", outer_checksum = "93AE1938DDE0DC0F7034F32C1BF0D4E89ACEBA82198A1FE21F604E849DA5F589" },
|
||||||
|
{ name = "rustler", version = "0.36.1", build_tools = ["mix"], requirements = ["jason", "toml"], otp_app = "rustler", source = "hex", outer_checksum = "F3FBA4AD272970E0D1BC62972FC4A99809651E54A125C5242DE9BAD4574B2D02" },
|
||||||
|
{ name = "rustler_precompiled", version = "0.8.2", build_tools = ["mix"], requirements = ["castore", "rustler"], otp_app = "rustler_precompiled", source = "hex", outer_checksum = "63D1BD5F8E23096D1FF851839923162096364BAC8656A4A3C00D1FFF8E83EE0A" },
|
||||||
{ name = "simplifile", version = "2.2.1", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "C88E0EE2D509F6D86EB55161D631657675AA7684DAB83822F7E59EB93D9A60E3" },
|
{ name = "simplifile", version = "2.2.1", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "C88E0EE2D509F6D86EB55161D631657675AA7684DAB83822F7E59EB93D9A60E3" },
|
||||||
{ name = "snag", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "snag", source = "hex", outer_checksum = "7E9F06390040EB5FAB392CE642771484136F2EC103A92AE11BA898C8167E6E17" },
|
{ name = "snag", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "snag", source = "hex", outer_checksum = "7E9F06390040EB5FAB392CE642771484136F2EC103A92AE11BA898C8167E6E17" },
|
||||||
{ name = "splitter", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "splitter", source = "hex", outer_checksum = "128FC521EE33B0012E3E64D5B55168586BC1B9C8D7B0D0CA223B68B0D770A547" },
|
{ name = "splitter", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "splitter", source = "hex", outer_checksum = "128FC521EE33B0012E3E64D5B55168586BC1B9C8D7B0D0CA223B68B0D770A547" },
|
||||||
@ -44,6 +51,7 @@ packages = [
|
|||||||
{ name = "temporary", version = "1.0.0", build_tools = ["gleam"], requirements = ["envoy", "exception", "filepath", "gleam_crypto", "gleam_stdlib", "simplifile"], otp_app = "temporary", source = "hex", outer_checksum = "51C0FEF4D72CE7CA507BD188B21C1F00695B3D5B09D7DFE38240BFD3A8E1E9B3" },
|
{ name = "temporary", version = "1.0.0", build_tools = ["gleam"], requirements = ["envoy", "exception", "filepath", "gleam_crypto", "gleam_stdlib", "simplifile"], otp_app = "temporary", source = "hex", outer_checksum = "51C0FEF4D72CE7CA507BD188B21C1F00695B3D5B09D7DFE38240BFD3A8E1E9B3" },
|
||||||
{ name = "term_size", version = "1.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "term_size", source = "hex", outer_checksum = "D00BD2BC8FB3EBB7E6AE076F3F1FF2AC9D5ED1805F004D0896C784D06C6645F1" },
|
{ name = "term_size", version = "1.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "term_size", source = "hex", outer_checksum = "D00BD2BC8FB3EBB7E6AE076F3F1FF2AC9D5ED1805F004D0896C784D06C6645F1" },
|
||||||
{ name = "tom", version = "1.1.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "tom", source = "hex", outer_checksum = "0910EE688A713994515ACAF1F486A4F05752E585B9E3209D8F35A85B234C2719" },
|
{ name = "tom", version = "1.1.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "tom", source = "hex", outer_checksum = "0910EE688A713994515ACAF1F486A4F05752E585B9E3209D8F35A85B234C2719" },
|
||||||
|
{ name = "toml", version = "0.7.0", build_tools = ["mix"], requirements = [], otp_app = "toml", source = "hex", outer_checksum = "0690246A2478C1DEFD100B0C9B89B4EA280A22BE9A7B313A8A058A2408A2FA70" },
|
||||||
{ name = "wisp", version = "1.6.0", build_tools = ["gleam"], requirements = ["directories", "exception", "gleam_crypto", "gleam_erlang", "gleam_http", "gleam_json", "gleam_stdlib", "logging", "marceau", "mist", "simplifile"], otp_app = "wisp", source = "hex", outer_checksum = "AE1C568FE30718C358D3B37666DF0A0743ECD96094AD98C9F4921475075F660A" },
|
{ name = "wisp", version = "1.6.0", build_tools = ["gleam"], requirements = ["directories", "exception", "gleam_crypto", "gleam_erlang", "gleam_http", "gleam_json", "gleam_stdlib", "logging", "marceau", "mist", "simplifile"], otp_app = "wisp", source = "hex", outer_checksum = "AE1C568FE30718C358D3B37666DF0A0743ECD96094AD98C9F4921475075F660A" },
|
||||||
{ name = "yamerl", version = "0.10.0", build_tools = ["rebar3"], requirements = [], otp_app = "yamerl", source = "hex", outer_checksum = "346ADB2963F1051DC837A2364E4ACF6EB7D80097C0F53CBDC3046EC8EC4B4E6E" },
|
{ name = "yamerl", version = "0.10.0", build_tools = ["rebar3"], requirements = [], otp_app = "yamerl", source = "hex", outer_checksum = "346ADB2963F1051DC837A2364E4ACF6EB7D80097C0F53CBDC3046EC8EC4B4E6E" },
|
||||||
]
|
]
|
||||||
@ -56,5 +64,6 @@ jot = { version = ">= 4.0.0 and < 5.0.0" }
|
|||||||
lustre = { version = ">= 5.0.2 and < 6.0.0" }
|
lustre = { version = ">= 5.0.2 and < 6.0.0" }
|
||||||
lustre_dev_tools = { version = ">= 1.7.1 and < 2.0.0" }
|
lustre_dev_tools = { version = ">= 1.7.1 and < 2.0.0" }
|
||||||
lustre_ssg = { git = "https://github.com/lustre-labs/ssg.git", ref = "v0.11.0" }
|
lustre_ssg = { git = "https://github.com/lustre-labs/ssg.git", ref = "v0.11.0" }
|
||||||
|
mdex = { version = ">= 0.6.1 and < 1.0.0" }
|
||||||
simplifile = { version = ">= 2.2.1 and < 3.0.0" }
|
simplifile = { version = ">= 2.2.1 and < 3.0.0" }
|
||||||
tom = { version = ">= 1.1.1 and < 2.0.0" }
|
tom = { version = ">= 1.1.1 and < 2.0.0" }
|
||||||
|
756
website/package-lock.json
generated
756
website/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,17 +1,7 @@
|
|||||||
{
|
{
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@djot/djot": "^0.3.2",
|
"@djot/djot": "^0.3.2",
|
||||||
"@tailwindcss/cli": "^4.1.10",
|
"@tailwindcss/cli": "^4.1.4",
|
||||||
"npm-watch": "^0.13.0",
|
"tailwindcss": "^4.1.4"
|
||||||
"tailwindcss": "^4.1.10"
|
|
||||||
},
|
|
||||||
"watch": {
|
|
||||||
"website": "src/*.gleam"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"website": "npm run gleam-build && npm run tailwind",
|
|
||||||
"gleam-build": "gleam run -m website",
|
|
||||||
"tailwind": "npx @tailwindcss/cli -o public/tailwind.css",
|
|
||||||
"watch": "npm-watch"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
pub const base_url = "https://rosettea.github.io/Hilbish/versions/new-website/"
|
pub const base_url = ""
|
||||||
|
|
||||||
pub fn base_url_join(cont: String) -> String {
|
pub fn base_url_join(cont: String) -> String {
|
||||||
base_url <> "/" <> cont
|
base_url <> "/" <> cont
|
||||||
}
|
}
|
||||||
|
26
website/src/md.ex
Normal file
26
website/src/md.ex
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
defmodule Parse do
|
||||||
|
def md_to_html(a) do
|
||||||
|
import MDEx
|
||||||
|
MDEx.to_html!(a, extension: [
|
||||||
|
strikethrough: true,
|
||||||
|
tagfilter: true,
|
||||||
|
table: true,
|
||||||
|
autolink: true,
|
||||||
|
tasklist: true,
|
||||||
|
footnotes: true,
|
||||||
|
shortcodes: true,
|
||||||
|
],
|
||||||
|
parse: [
|
||||||
|
smart: true,
|
||||||
|
relaxed_tasklist_matching: true,
|
||||||
|
relaxed_autolinks: true
|
||||||
|
],
|
||||||
|
render: [
|
||||||
|
github_pre_lang: true,
|
||||||
|
unsafe_: true,
|
||||||
|
],
|
||||||
|
features: [
|
||||||
|
sanitize: true
|
||||||
|
])
|
||||||
|
end
|
||||||
|
end
|
2
website/src/md.gleam
Normal file
2
website/src/md.gleam
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
@external(erlang, "Elixir.Parse", "md_to_html")
|
||||||
|
pub fn md_to_html(md: String) -> a
|
@ -11,137 +11,115 @@ import jot
|
|||||||
import post
|
import post
|
||||||
|
|
||||||
pub fn page(p: post.Post, doc_pages_list) -> element.Element(a) {
|
pub fn page(p: post.Post, doc_pages_list) -> element.Element(a) {
|
||||||
html.div([attribute.class("flex-auto flex flex-col overflow-none")], [
|
html.div([attribute.class("flex flex-col")], [
|
||||||
html.div(
|
html.div([attribute.class("h-10 flex py-2 px-4 border-b border-b-zinc-300 w-full gap-2 backdrop-blur-sm bg-zinc-300/50 dark:bg-zinc-800/50 z-50")], [
|
||||||
[
|
html.label([attribute.for("sidebar-toggle"), attribute.class("cursor-pointer")], [
|
||||||
attribute.class(
|
element.unsafe_raw_html("", "tag", [], "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\" width=\"24px\" class=\"fill-black\"><path d=\"M120-240v-80h240v80H120Zm0-200v-80h480v80H120Zm0-200v-80h720v80H120Z\"/></svg>"),
|
||||||
"sm:hidden h-10 flex py-2 px-4 border-b border-b-zinc-300 w-full gap-2 backdrop-blur-sm bg-zinc-300/50 dark:bg-zinc-800/50 z-50",
|
]),
|
||||||
),
|
html.span([], [element.text(p.title)])
|
||||||
],
|
]),
|
||||||
[
|
html.div([attribute.class("grid")], [
|
||||||
html.label(
|
html.input([attribute.type_("checkbox"), attribute.id("sidebar-toggle"), attribute.class("peer hidden")]),
|
||||||
[attribute.for("sidebar-toggle"), attribute.class("cursor-pointer")],
|
html.div([attribute.class("border-r border-r-zinc-300 col-start-1 row-start-1 sticky top-22 sm:top-12 h-full sm:h-svh bg-neutral-200 dark:bg-neutral-900 basis-3/5 transition-transform duration-300 -translate-x-full peer-checked:translate-x-0 z-30")], [
|
||||||
[
|
html.div([attribute.class("p-4 -mb-4 overflow-y-auto h-full")], [
|
||||||
element.unsafe_raw_html(
|
html.h2([attribute.class("text-xl font-semibold mb-4")], [element.text("Sidebar")]),
|
||||||
"",
|
html.ul([], list.map(doc_pages_list, fn(post: #(String, post.Post)) {
|
||||||
"tag",
|
html.li([attribute.class("mb-2")], [element.text(post.1.title)])
|
||||||
[],
|
}))
|
||||||
"<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\" width=\"24px\" class=\"fill-black\"><path d=\"M120-240v-80h240v80H120Zm0-200v-80h480v80H120Zm0-200v-80h720v80H120Z\"/></svg>",
|
])
|
||||||
),
|
]),
|
||||||
],
|
html.main([attribute.class("col-start-1 row-start-1 transition-all duration-300 peer-checked:filter peer-checked:blur-sm peer-checked:bg-black/30 px-4 pt-2")], [
|
||||||
),
|
html.h1([attribute.class("font-bold text-4xl")], [element.text(p.title)]),
|
||||||
html.span([], [element.text(p.title)]),
|
// todo: add date of publishing
|
||||||
],
|
//html.time([], [])
|
||||||
),
|
//html.small([], [element.text({{p.contents |> string.split(" ") |> list.length} / 200} |> int.to_string <> " min read")]),
|
||||||
html.div([attribute.class("h-full sm:flex grid")], [
|
//element.unsafe_raw_html("namespace", "Tag", [], render_doc(p.contents))
|
||||||
html.input([
|
..render_doc(p.contents)
|
||||||
attribute.type_("checkbox"),
|
])
|
||||||
attribute.id("sidebar-toggle"),
|
])
|
||||||
attribute.class("peer hidden"),
|
])
|
||||||
]),
|
|
||||||
html.div(
|
|
||||||
[
|
|
||||||
attribute.class(
|
|
||||||
"p-4 border-r border-r-zinc-300 col-start-1 row-start-1 bg-neutral-200 dark:bg-neutral-900 basis-2/10 transition-transform duration-300 -translate-x-full peer-checked:translate-x-0 sm:translate-x-0 z-30",
|
|
||||||
),
|
|
||||||
],
|
|
||||||
[
|
|
||||||
html.ul(
|
|
||||||
[],
|
|
||||||
list.map(doc_pages_list, fn(post: #(String, post.Post)) {
|
|
||||||
html.li([attribute.class("mb-2")], [
|
|
||||||
html.a([attribute.href(post.0)], [
|
|
||||||
element.text({ post.1 }.title),
|
|
||||||
]),
|
|
||||||
])
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
html.main(
|
|
||||||
[
|
|
||||||
attribute.class(
|
|
||||||
"mb-4 h-full overflow-y-auto basis-7/7 col-start-1 row-start-1 transition-all duration-300 peer-checked:filter peer-checked:blur-sm peer-checked:bg-black/30 px-4 pt-2",
|
|
||||||
),
|
|
||||||
],
|
|
||||||
[
|
|
||||||
html.h1([attribute.class("mb-2 font-bold text-4xl")], [
|
|
||||||
element.text(p.title),
|
|
||||||
]),
|
|
||||||
// todo: add date of publishing
|
|
||||||
//html.time([], [])
|
|
||||||
//html.small([], [element.text({{p.contents |> string.split(" ") |> list.length} / 200} |> int.to_string <> " min read")]),
|
|
||||||
//element.unsafe_raw_html("namespace", "Tag", [], render_doc(p.contents))
|
|
||||||
..render_doc(p.contents)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
]),
|
|
||||||
])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_doc(md: String) {
|
fn render_doc(md: String) {
|
||||||
let renderer =
|
let renderer = djot.Renderer(
|
||||||
djot.Renderer(
|
..djot.default_renderer(),
|
||||||
..djot.default_renderer(),
|
heading: fn(attrs, level, content) {
|
||||||
heading: fn(attrs, level, content) {
|
let size = case level {
|
||||||
let size = case level {
|
1 -> "text-4xl"
|
||||||
1 -> "text-4xl"
|
2 -> "text-3xl"
|
||||||
2 -> "text-3xl"
|
3 -> "text-2xl"
|
||||||
3 -> "text-2xl"
|
_ -> "text-xl"
|
||||||
_ -> "text-xl"
|
}
|
||||||
}
|
let attr = dict.insert(attrs, "class", "font-bold " <> size)
|
||||||
let attr =
|
|
||||||
dict.insert(
|
|
||||||
attrs,
|
|
||||||
"class",
|
|
||||||
"mb-1 text-neutral-800 dark:text-neutral-300 font-bold " <> size,
|
|
||||||
)
|
|
||||||
|
|
||||||
case level {
|
case level {
|
||||||
1 -> html.h1(to_attr(attr), content)
|
1 -> html.h1(to_attr(attr), content)
|
||||||
2 -> html.h2(to_attr(attr), content)
|
2 -> html.h2(to_attr(attr), content)
|
||||||
3 -> html.h3(to_attr(attr), content)
|
3 -> html.h3(to_attr(attr), content)
|
||||||
_ -> html.p(to_attr(attr), content)
|
_ -> html.p(to_attr(attr), content)
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
code: fn(content) {
|
)
|
||||||
html.code([attribute.class("text-violet-600 dark:text-violet-400")], [
|
djot.render(md, renderer)
|
||||||
element.text(content),
|
|
||||||
])
|
|
||||||
},
|
|
||||||
)
|
|
||||||
djot.render(md, renderer)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_attr(attrs) {
|
fn to_attr(attrs) {
|
||||||
use attrs, key, val <- dict.fold(attrs, [])
|
use attrs, key, val <- dict.fold(attrs, [])
|
||||||
[attribute.attribute(key, val), ..attrs]
|
[attribute.attribute(key, val), ..attrs]
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_doc_(md: String) -> String {
|
fn render_doc_(md: String) -> String {
|
||||||
// w-full m-2 p-2 bg-neutral-700
|
// w-full m-2 p-2 bg-neutral-700
|
||||||
let doc = jot.parse(md)
|
let doc = jot.parse(md)
|
||||||
let updated_content =
|
let updated_content = list.map(doc.content, fn(container) {
|
||||||
list.map(doc.content, fn(container) {
|
case container {
|
||||||
case container {
|
jot.Heading(attributes, level, content) -> {
|
||||||
jot.Heading(attributes, level, content) -> {
|
let size = case level {
|
||||||
let size = case level {
|
1 -> "text-4xl"
|
||||||
1 -> "text-4xl"
|
2 -> "text-3xl"
|
||||||
2 -> "text-3xl"
|
3 -> "text-2xl"
|
||||||
3 -> "text-2xl"
|
_ -> "text-xl"
|
||||||
_ -> "text-xl"
|
}
|
||||||
}
|
let attr = dict.insert(attributes, "class", "font-bold " <> size)
|
||||||
let attr = dict.insert(attributes, "class", "font-bold " <> size)
|
jot.Heading(attr, level, content)
|
||||||
jot.Heading(attr, level, content)
|
}
|
||||||
}
|
_ -> container
|
||||||
_ -> container
|
}
|
||||||
}
|
})
|
||||||
})
|
echo doc
|
||||||
echo doc
|
|
||||||
|
|
||||||
jot.document_to_html(jot.Document(
|
jot.document_to_html(jot.Document(
|
||||||
content: updated_content,
|
content: updated_content,
|
||||||
references: doc.references,
|
references: doc.references,
|
||||||
footnotes: doc.footnotes,
|
footnotes: doc.footnotes
|
||||||
))
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn page_(p: post.Post, doc_pages_list) -> element.Element(a) {
|
||||||
|
html.div([attribute.class("relative h-screen flex")], [
|
||||||
|
html.div([attribute.class("-mt-2 -mx-4 py-2 px-4 border-b border-b-zinc-300 flex gap-2 font-semibold")], [
|
||||||
|
html.label([attribute.for("sidebar-toggle"), attribute.class("cursor-pointer")], [
|
||||||
|
element.unsafe_raw_html("", "tag", [], "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\" width=\"24px\" class=\"fill-black\"><path d=\"M120-240v-80h240v80H120Zm0-200v-80h480v80H120Zm0-200v-80h720v80H120Z\"/></svg>"),
|
||||||
|
]),
|
||||||
|
html.span([], [element.text(p.title)])
|
||||||
|
]),
|
||||||
|
html.div([attribute.class("relative flex")], [
|
||||||
|
html.div([attribute.class("absolute top-0 left-0 h-full bg-gray-200 w-64 transition-transform duration-300 -translate-x-full peer-checked:translate-x-0 z-30")], [
|
||||||
|
html.div([attribute.class("p-4")], [
|
||||||
|
html.h2([attribute.class("text-xl font-semibold mb-4")], [element.text("Sidebar")]),
|
||||||
|
html.ul([], [
|
||||||
|
html.li([attribute.class("mb-2")], [element.text("Test")])
|
||||||
|
])
|
||||||
|
])
|
||||||
|
]),
|
||||||
|
html.input([attribute.type_("checkbox"), attribute.id("sidebar-toggle"), attribute.class("peer hidden")]),
|
||||||
|
html.main([attribute.class("flex-1 transition-all duration-300 peer-checked:filter peer-checked:blur-sm peer-checked:opacity-50")], [
|
||||||
|
html.h1([], [element.text(p.title)]),
|
||||||
|
// todo: add date of publishing
|
||||||
|
//html.time([], [])
|
||||||
|
//html.small([], [element.text({{p.contents |> string.split(" ") |> list.length} / 200} |> int.to_string <> " min read")]),
|
||||||
|
//element.unsafe_raw_html("namespace", "Tag", [], md.md_to_html(p.contents))
|
||||||
|
])
|
||||||
|
])
|
||||||
|
])
|
||||||
}
|
}
|
||||||
|
@ -1,298 +1,204 @@
|
|||||||
import gleam/io
|
|
||||||
import gleam/list
|
|
||||||
import gleam/option
|
import gleam/option
|
||||||
|
import gleam/dict
|
||||||
|
import gleam/io
|
||||||
import gleam/order
|
import gleam/order
|
||||||
|
import gleam/list
|
||||||
import gleam/string
|
import gleam/string
|
||||||
|
|
||||||
import glaml
|
|
||||||
import lustre/attribute
|
import lustre/attribute
|
||||||
import lustre/element
|
import lustre/element
|
||||||
import lustre/element/html
|
import lustre/element/html
|
||||||
import lustre/ssg
|
import lustre/ssg
|
||||||
import lustre/ssg/djot
|
import lustre/ssg/djot
|
||||||
import simplifile
|
|
||||||
import tom
|
import tom
|
||||||
|
import simplifile
|
||||||
|
import glaml
|
||||||
|
|
||||||
import conf
|
import conf
|
||||||
import pages/doc
|
|
||||||
import pages/index
|
|
||||||
import post
|
import post
|
||||||
|
import pages/index
|
||||||
|
import pages/doc
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let assert Ok(files) = simplifile.get_files("./content")
|
let assert Ok(files) = simplifile.get_files("./content")
|
||||||
let posts =
|
let posts = list.map(files, fn(path: String) {
|
||||||
list.map(files, fn(path: String) {
|
let assert Ok(ext) = path |> string.split(".") |> list.last
|
||||||
let assert Ok(ext) = path |> string.split(".") |> list.last
|
let slug = path |> string.replace("./content", "") |> string.drop_end({ext |> string.length()} + 1)
|
||||||
let slug =
|
let assert Ok(name) = slug |> string.split("/") |> list.last
|
||||||
path
|
|
||||||
|> string.replace("./content", "")
|
|
||||||
|> string.drop_end({ ext |> string.length() } + 1)
|
|
||||||
let assert Ok(name) = slug |> string.split("/") |> list.last
|
|
||||||
|
|
||||||
let slug = case name {
|
let assert Ok(content) = simplifile.read(path)
|
||||||
"_index" -> slug |> string.drop_end({ "_index" |> string.length() } + 1)
|
let frontmatter = djot.frontmatter(content)
|
||||||
_ -> slug
|
let metadata = case frontmatter {
|
||||||
}
|
Ok(frntmtr) -> {
|
||||||
|
let assert Ok([metadata]) = glaml.parse_string(frntmtr)
|
||||||
|
option.Some(metadata)
|
||||||
|
}
|
||||||
|
Error(_) -> option.None
|
||||||
|
}
|
||||||
|
let content = djot.content(content)
|
||||||
|
|
||||||
let assert Ok(content) = simplifile.read(path)
|
let title = case metadata {
|
||||||
let frontmatter = djot.frontmatter(content)
|
option.Some(metadata) -> {
|
||||||
let metadata = case frontmatter {
|
case glaml.select_sugar(glaml.document_root(metadata), "title") {
|
||||||
Ok(frntmtr) -> {
|
Ok(glaml.NodeStr(s)) -> s
|
||||||
let assert Ok([metadata]) = glaml.parse_string(frntmtr)
|
_ -> ""
|
||||||
option.Some(metadata)
|
}
|
||||||
}
|
|
||||||
Error(_) -> option.None
|
|
||||||
}
|
|
||||||
let content = djot.content(content)
|
|
||||||
|
|
||||||
let title = case metadata {
|
}
|
||||||
option.Some(metadata) -> {
|
option.None -> ""
|
||||||
case glaml.select_sugar(glaml.document_root(metadata), "title") {
|
}
|
||||||
Ok(glaml.NodeStr(s)) -> s
|
|
||||||
_ -> ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
option.None -> ""
|
|
||||||
}
|
|
||||||
|
|
||||||
let assert Ok(filename) = path |> string.split("/") |> list.last
|
let assert Ok(filename) = path |> string.split("/") |> list.last
|
||||||
#(slug, post.Post(name, title, slug, metadata, content))
|
#(slug, post.Post(name, title, slug, metadata, content))
|
||||||
})
|
})
|
||||||
|
|
||||||
let doc_pages =
|
let doc_pages = list.filter(posts, fn(page) {
|
||||||
list.filter(posts, fn(page) {
|
let isdoc = is_doc_page(page.0)
|
||||||
let isdoc = is_doc_page(page.0)
|
//io.debug(page.0)
|
||||||
//io.debug(page.0)
|
//io.debug(isdoc)
|
||||||
//io.debug(isdoc)
|
isdoc
|
||||||
isdoc
|
}) |> list.filter(fn(page) {
|
||||||
})
|
case page.1.metadata {
|
||||||
|> list.filter(fn(page) {
|
option.Some(_) -> True
|
||||||
case { page.1 }.metadata {
|
option.None -> False
|
||||||
option.Some(_) -> True
|
}
|
||||||
option.None -> False
|
}) |> list.sort(fn(p1, p2) {
|
||||||
}
|
//io.debug(p1)
|
||||||
})
|
//io.debug(p2)
|
||||||
|> list.sort(fn(p1, p2) {
|
let assert option.Some(p1_metadata) = p1.1.metadata
|
||||||
//io.debug(p1)
|
let p1_weight = case glaml.select_sugar(glaml.document_root(p1_metadata), "weight") {
|
||||||
//io.debug(p2)
|
Ok(glaml.NodeInt(w)) -> w
|
||||||
let assert option.Some(p1_metadata) = { p1.1 }.metadata
|
_ -> 0
|
||||||
let p1_weight = case
|
}
|
||||||
glaml.select_sugar(glaml.document_root(p1_metadata), "weight")
|
|
||||||
{
|
|
||||||
Ok(glaml.NodeInt(w)) -> w
|
|
||||||
_ -> 0
|
|
||||||
}
|
|
||||||
|
|
||||||
let assert option.Some(p2_metadata) = { p2.1 }.metadata
|
let assert option.Some(p2_metadata) = p2.1.metadata
|
||||||
let p2_weight = case
|
let p2_weight = case glaml.select_sugar(glaml.document_root(p2_metadata), "weight") {
|
||||||
glaml.select_sugar(glaml.document_root(p2_metadata), "weight")
|
Ok(glaml.NodeInt(w)) -> w
|
||||||
{
|
_ -> 0
|
||||||
Ok(glaml.NodeInt(w)) -> w
|
}
|
||||||
_ -> 0
|
|
||||||
}
|
|
||||||
|
|
||||||
case p1_weight == 0 {
|
case p1_weight == 0 {
|
||||||
True -> {
|
True -> order.Eq
|
||||||
case p1_weight == 0 {
|
False -> {
|
||||||
True -> order.Eq
|
case p1_weight < p2_weight {
|
||||||
False ->
|
True -> order.Lt
|
||||||
case p1_weight > p2_weight {
|
False -> order.Gt
|
||||||
True -> order.Lt
|
}
|
||||||
False -> order.Gt
|
}
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
}
|
|
||||||
False -> {
|
|
||||||
case p1_weight > p2_weight {
|
|
||||||
True -> order.Lt
|
|
||||||
False -> order.Gt
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
let build =
|
let build = ssg.new("./public")
|
||||||
ssg.new("./public")
|
|> ssg.add_static_dir("static")
|
||||||
|> ssg.add_static_dir("static")
|
|> ssg.add_static_route("/", create_page(index.page()))
|
||||||
|> ssg.add_static_route("/", create_page(index.page()))
|
|> list.fold(posts, _, fn(config, post) {
|
||||||
|> list.fold(posts, _, fn(config, post) {
|
let route = case post.1.name {
|
||||||
let route = case { post.1 }.name {
|
"_index" -> post.0 |> string.drop_end("_index" |> string.length())
|
||||||
"_index" -> post.0 |> string.drop_end("_index" |> string.length())
|
_ -> post.0
|
||||||
_ -> post.0
|
}
|
||||||
}
|
|
||||||
|
|
||||||
let page = case is_doc_page(post.0) {
|
|
||||||
True -> doc.page(post.1, doc_pages)
|
|
||||||
False -> doc.page(post.1, doc_pages)
|
|
||||||
}
|
|
||||||
ssg.add_static_route(config, route, create_page(page))
|
|
||||||
})
|
|
||||||
|> ssg.use_index_routes
|
|
||||||
|> ssg.build
|
|
||||||
|
|
||||||
case build {
|
let page = case is_doc_page(post.0) {
|
||||||
Ok(_) -> io.println("Website successfully built!")
|
True -> doc.page(post.1, doc_pages)
|
||||||
Error(e) -> {
|
False -> doc.page(post.1, doc_pages)
|
||||||
io.debug(e)
|
}
|
||||||
io.println("Website could not be built.")
|
ssg.add_static_route(config, route, create_page(page))
|
||||||
}
|
})
|
||||||
}
|
|> ssg.use_index_routes
|
||||||
|
|> ssg.build
|
||||||
|
|
||||||
|
case build {
|
||||||
|
Ok(_) -> io.println("Website successfully built!")
|
||||||
|
Error(e) -> {
|
||||||
|
io.debug(e)
|
||||||
|
io.println("Website could not be built.")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_doc_page(slug: String) {
|
fn is_doc_page(slug: String) {
|
||||||
case slug {
|
case slug {
|
||||||
"/docs" <> _ -> True
|
"/docs" <> _ -> True
|
||||||
_ -> False
|
_ -> False
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn nav() -> element.Element(a) {
|
fn nav() -> element.Element(a) {
|
||||||
html.nav(
|
html.nav([attribute.class("flex sticky top-0 w-full z-50 border-b border-b-zinc-300 backdrop-blur-md h-12")], [
|
||||||
[
|
html.div([attribute.class("flex my-auto px-2")], [
|
||||||
attribute.class(
|
html.div([], [
|
||||||
"bg-stone-50/80 dark:bg-neutral-900/80 flex justify-around sticky items-center top-0 w-full z-50 border-b border-b-zinc-300 backdrop-blur-md h-18",
|
html.a([attribute.href("/"), attribute.class("flex items-center gap-1")], [
|
||||||
),
|
html.img([
|
||||||
],
|
attribute.src("/hilbish-flower.png"),
|
||||||
[
|
attribute.class("h-6")
|
||||||
html.div([attribute.class("flex my-auto px-2")], [
|
]),
|
||||||
html.div([], [
|
html.span([
|
||||||
html.a(
|
attribute.class("self-center text-2xl")
|
||||||
[attribute.href("/"), attribute.class("flex items-center gap-1")],
|
], [
|
||||||
[
|
element.text("Hilbish"),
|
||||||
html.img([
|
]),
|
||||||
attribute.src("/hilbish-flower.png"),
|
]),
|
||||||
attribute.class("h-16"),
|
])
|
||||||
]),
|
]),
|
||||||
html.span([attribute.class("self-center text-3xl font-medium")], [
|
])
|
||||||
element.text("Hilbish"),
|
|
||||||
]),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
]),
|
|
||||||
]),
|
|
||||||
html.div(
|
|
||||||
[attribute.class("flex gap-3 dark:text-pink-300 text-pink-600")],
|
|
||||||
[
|
|
||||||
html.a([attribute.href("/")], [element.text("Home")]),
|
|
||||||
html.a([attribute.href("/install")], [element.text("Install")]),
|
|
||||||
html.a([attribute.href("/docs")], [element.text("Docs")]),
|
|
||||||
html.a([attribute.href("/blog")], [element.text("Blog")]),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn footer() -> element.Element(a) {
|
fn footer() -> element.Element(a) {
|
||||||
html.footer(
|
html.footer([attribute.class("py-4 px-6 flex flex-row justify-around border-t border-t-zinc-300")], [
|
||||||
[
|
html.div([attribute.class("flex flex-col")], [
|
||||||
attribute.class(
|
html.a([attribute.href(conf.base_url), attribute.class("flex items-center gap-1")], [
|
||||||
"py-4 px-6 flex flex-row justify-around border-t border-t-zinc-300",
|
html.img([
|
||||||
),
|
attribute.src("/hilbish-flower.png"),
|
||||||
],
|
attribute.class("h-24")
|
||||||
[
|
]),
|
||||||
html.div([attribute.class("flex flex-col")], [
|
html.span([
|
||||||
html.a(
|
attribute.class("self-center text-6xl")
|
||||||
[
|
], [
|
||||||
attribute.href(conf.base_url),
|
element.text("Hilbish"),
|
||||||
attribute.class("flex items-center gap-1"),
|
]),
|
||||||
],
|
]),
|
||||||
[
|
html.span([attribute.class("text-xl")], [element.text("The Moon-powered shell!")]),
|
||||||
html.img([
|
html.span([attribute.class("text-light text-neutral-500")], [element.text("MIT License, copyright sammyette 2025")])
|
||||||
attribute.src("/hilbish-flower.png"),
|
]),
|
||||||
attribute.class("h-24"),
|
html.div([attribute.class("flex flex-col")], [
|
||||||
]),
|
link("https://github.com/Rosettea/Hilbish", "GitHub")
|
||||||
html.span([attribute.class("self-center text-6xl")], [
|
])
|
||||||
element.text("Hilbish"),
|
])
|
||||||
]),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
html.span([attribute.class("text-xl")], [
|
|
||||||
element.text("The Moon-powered shell!"),
|
|
||||||
]),
|
|
||||||
html.span([attribute.class("text-light text-neutral-500")], [
|
|
||||||
element.text("MIT License, copyright sammyette 2025"),
|
|
||||||
]),
|
|
||||||
]),
|
|
||||||
html.div([attribute.class("flex flex-col")], [
|
|
||||||
link("https://github.com/Rosettea/Hilbish", "GitHub"),
|
|
||||||
]),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_page(content: element.Element(a)) -> element.Element(a) {
|
fn create_page(content: element.Element(a)) -> element.Element(a) {
|
||||||
let description =
|
let description = "Something Unique. Hilbish is the new interactive shell for Lua fans. Extensible, scriptable, configurable: All in Lua."
|
||||||
"Something Unique. Hilbish is the new interactive shell for Lua fans. Extensible, scriptable, configurable: All in Lua."
|
|
||||||
|
|
||||||
html.html(
|
html.html([attribute.class("bg-stone-50 dark:bg-neutral-900 text-black dark:text-white")], [
|
||||||
[
|
html.head([], [
|
||||||
attribute.class(
|
html.meta([
|
||||||
"bg-stone-50 dark:bg-neutral-900 text-black dark:text-white",
|
attribute.name("viewport"),
|
||||||
),
|
attribute.attribute("content", "width=device-width, initial-scale=1.0")
|
||||||
],
|
]),
|
||||||
[
|
html.link([
|
||||||
html.head([], [
|
attribute.rel("stylesheet"),
|
||||||
html.meta([
|
attribute.href(conf.base_url_join("tailwind.css"))
|
||||||
attribute.name("viewport"),
|
]),
|
||||||
attribute.attribute(
|
html.title([], "Hilbish"),
|
||||||
"content",
|
html.meta([attribute.name("theme-color"), attribute.content("#ff89dd")]),
|
||||||
"width=device-width, initial-scale=1.0",
|
html.meta([attribute.content(conf.base_url_join("hilbish-flower.png")), attribute.attribute("property", "og:image")]),
|
||||||
),
|
html.meta([attribute.content("Hilbish"), attribute.attribute("property", "og:title")]), // this should be same as title
|
||||||
]),
|
html.meta([attribute.content("Hilbish"), attribute.attribute("property", "og:site_name")]),
|
||||||
html.link([
|
html.meta([attribute.content("website"), attribute.attribute("property", "og:type")]),
|
||||||
attribute.rel("stylesheet"),
|
html.meta([attribute.content(description), attribute.attribute("property", "og:description")]),
|
||||||
attribute.href(conf.base_url_join("tailwind.css")),
|
html.meta([attribute.content(description), attribute.name("description")]),
|
||||||
]),
|
html.meta([attribute.name("keywords"), attribute.content("Lua,Shell,Hilbish,Linux,zsh,bash")]),
|
||||||
html.title([], "Hilbish"),
|
html.meta([attribute.content(conf.base_url), attribute.attribute("property", "og:url")])
|
||||||
html.meta([attribute.name("theme-color"), attribute.content("#ff89dd")]),
|
]),
|
||||||
html.meta([
|
html.body([attribute.class("min-h-screen flex flex-col")], [
|
||||||
attribute.content(conf.base_url_join("hilbish-flower.png")),
|
nav(),
|
||||||
attribute.attribute("property", "og:image"),
|
content,
|
||||||
]),
|
footer(),
|
||||||
html.meta([
|
])
|
||||||
attribute.content("Hilbish"),
|
])
|
||||||
attribute.attribute("property", "og:title"),
|
|
||||||
]),
|
|
||||||
// this should be same as title
|
|
||||||
html.meta([
|
|
||||||
attribute.content("Hilbish"),
|
|
||||||
attribute.attribute("property", "og:site_name"),
|
|
||||||
]),
|
|
||||||
html.meta([
|
|
||||||
attribute.content("website"),
|
|
||||||
attribute.attribute("property", "og:type"),
|
|
||||||
]),
|
|
||||||
html.meta([
|
|
||||||
attribute.content(description),
|
|
||||||
attribute.attribute("property", "og:description"),
|
|
||||||
]),
|
|
||||||
html.meta([
|
|
||||||
attribute.content(description),
|
|
||||||
attribute.name("description"),
|
|
||||||
]),
|
|
||||||
html.meta([
|
|
||||||
attribute.name("keywords"),
|
|
||||||
attribute.content("Lua,Shell,Hilbish,Linux,zsh,bash"),
|
|
||||||
]),
|
|
||||||
html.meta([
|
|
||||||
attribute.content(conf.base_url),
|
|
||||||
attribute.attribute("property", "og:url"),
|
|
||||||
]),
|
|
||||||
]),
|
|
||||||
html.body([attribute.class("min-h-screen flex flex-col")], [
|
|
||||||
nav(),
|
|
||||||
content,
|
|
||||||
footer(),
|
|
||||||
]),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn link(url: String, text: String) {
|
fn link(url: String, text: String) {
|
||||||
html.a([attribute.href(url)], [
|
html.a([attribute.href(url)], [
|
||||||
html.span([attribute.class("text-pink-300 text-light")], [
|
html.span([attribute.class("text-pink-300 text-light")], [element.text(text)])
|
||||||
element.text(text),
|
])
|
||||||
]),
|
|
||||||
])
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user