2
2
mirror of https://github.com/Hilbis/Hilbish synced 2025-07-01 16:52:03 +00:00

feat: lots of changes

- doc gen is done differently
- docs look better too
- ... im lazy to rewrite the commit because i lost it because GPG_TTY ISNT SET FOR SOME REASON
This commit is contained in:
sammyette 2025-06-12 19:35:54 -04:00
parent 54f11e46b7
commit 85c197d64b
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD
40 changed files with 6628 additions and 3439 deletions

View File

@ -1,16 +1,18 @@
package main
import (
"encoding/json"
"fmt"
"path/filepath"
"go/ast"
"go/doc"
"go/parser"
"go/token"
"os"
"path/filepath"
"regexp"
"strings"
"os"
"sync"
//"regexp"
//"sync"
)
var header = `---
@ -32,47 +34,48 @@ type emmyPiece struct {
}
type module struct {
Types []docPiece
Docs []docPiece
Fields []docPiece
Properties []docPiece
ShortDescription string
Description string
ParentModule string
HasInterfaces bool
HasTypes bool
Name string `json:"name"`
ShortDescription string `json:"shortDescription"`
Description string `json:"description"`
ParentModule string `json:"parent,omitempty"`
HasInterfaces bool `json:"-"`
HasTypes bool `json:"-"`
Properties []docPiece `json:"properties"`
Fields []docPiece `json:"fields"`
Types []docPiece `json:"types,omitempty"`
Docs []docPiece `json:"docs"`
Interfaces map[string]module `json:"interfaces,omitempty"`
}
type param struct{
type param struct {
Name string
Type string
Doc []string
}
type docPiece struct {
Doc []string
FuncSig string
FuncName string
Interfacing string
ParentModule string
GoFuncName string
IsInterface bool
IsMember bool
IsType bool
Fields []docPiece
Properties []docPiece
Params []param
Tags map[string][]tag
FuncName string `json:"name"`
Doc []string `json:"description"`
ParentModule string `json:"parent,omitempty"`
Interfacing string `json:"interfaces,omitempty"`
FuncSig string `json:"signature,omitempty"`
GoFuncName string `json:"goFuncName,omitempty"`
IsInterface bool `json:"isInterface"`
IsMember bool `json:"isMember"`
IsType bool `json:"isType"`
Fields []docPiece `json:"fields,omitempty"`
Properties []docPiece `json:"properties,omitempty"`
Params []param `json:"params,omitempty"`
Tags map[string][]tag `json:"tags,omitempty"`
}
type tag struct {
id string
fields []string
startIdx int
Id string `json:"id"`
Fields []string `json:"fields"`
StartIdx int `json:"startIdx`
}
var docs = make(map[string]module)
var interfaceDocs = make(map[string]module)
var emmyDocs = make(map[string][]emmyPiece)
var typeTable = make(map[string][]string) // [0] = parentMod, [1] = interfaces
var prefix = map[string]string{
@ -99,17 +102,17 @@ func getTagsAndDocs(docs string) (map[string][]tag, []string) {
id = tagParts[1]
}
tags[tagParts[0]] = []tag{
{id: id, startIdx: idx},
{Id: id, StartIdx: idx},
}
if len(tagParts) >= 2 {
tags[tagParts[0]][0].fields = tagParts[2:]
tags[tagParts[0]][0].Fields = tagParts[2:]
}
} else {
if tagParts[0] == "example" {
exampleIdx := tags["example"][0].startIdx
exampleCode := pts[exampleIdx+1:idx]
exampleIdx := tags["example"][0].StartIdx
exampleCode := pts[exampleIdx+1 : idx]
tags["example"][0].fields = exampleCode
tags["example"][0].Fields = exampleCode
parts = strings.Split(strings.Replace(strings.Join(parts, "\n"), strings.TrimPrefix(strings.Join(exampleCode, "\n"), "#example\n"), "", -1), "\n")
continue
}
@ -119,8 +122,8 @@ func getTagsAndDocs(docs string) (map[string][]tag, []string) {
fleds = tagParts[2:]
}
tags[tagParts[0]] = append(tags[tagParts[0]], tag{
id: tagParts[1],
fields: fleds,
Id: tagParts[1],
Fields: fleds,
})
}
} else {
@ -135,8 +138,8 @@ func docPieceTag(tagName string, tags map[string][]tag) []docPiece {
dps := []docPiece{}
for _, tag := range tags[tagName] {
dps = append(dps, docPiece{
FuncName: tag.id,
Doc: tag.fields,
FuncName: tag.Id,
Doc: tag.Fields,
})
}
@ -157,7 +160,7 @@ func setupDocType(mod string, typ *doc.Type) *docPiece {
typeDoc := []string{}
if inInterface {
interfaces = tags["interface"][0].id
interfaces = tags["interface"][0].Id
}
fields := docPieceTag("field", tags)
@ -232,7 +235,7 @@ start:
funcdoc := []string{}
if inInterface {
interfaces = tags["interface"][0].id
interfaces = tags["interface"][0].Id
funcName = interfaces + "." + strings.Split(funcsig, "(")[0]
}
em := emmyPiece{FuncName: funcName}
@ -244,9 +247,9 @@ start:
params = make([]param, len(paramsRaw))
for i, p := range paramsRaw {
params[i] = param{
Name: p.id,
Type: p.fields[0],
Doc: p.fields[1:],
Name: p.Id,
Type: p.Fields[0],
Doc: p.Fields[1:],
}
}
}
@ -300,35 +303,19 @@ start:
}
func main() {
if len(os.Args) == 1 {
fset := token.NewFileSet()
os.Mkdir("docs", 0777)
os.RemoveAll("docs/api")
os.Mkdir("docs/api", 0777)
f, err := os.Create("docs/api/_index.md")
if err != nil {
panic(err)
}
f.WriteString(`---
title: API
layout: doc
weight: -100
menu: docs
---
Welcome to the API documentation for Hilbish. This documents Lua functions
provided by Hilbish.
`)
f.Close()
os.Mkdir("defs", 0777)
/*
os.Mkdir("emmyLuaDocs", 0777)
*/
dirs := []string{"./", "./util"}
filepath.Walk("golibs/", func (path string, info os.FileInfo, err error) error {
filepath.Walk("golibs/", func(path string, info os.FileInfo, err error) error {
if !info.IsDir() {
return nil
}
dirs = append(dirs, "./" + path)
dirs = append(dirs, "./"+path)
return nil
})
@ -401,6 +388,7 @@ provided by Hilbish.
modname := piece.ParentModule + "." + piece.Interfacing
if interfaceModules[modname] == nil {
interfaceModules[modname] = &module{
Name: modname,
ParentModule: piece.ParentModule,
}
}
@ -443,6 +431,7 @@ provided by Hilbish.
docs[mod] = newDoc
} else {
docs[mod] = module{
Name: mod,
Types: filteredTypePieces,
Docs: filteredPieces,
ShortDescription: shortDesc,
@ -450,21 +439,83 @@ provided by Hilbish.
HasInterfaces: hasInterfaces,
Properties: docPieceTag("property", tags),
Fields: docPieceTag("field", tags),
Interfaces: make(map[string]module),
}
}
}
for key, mod := range interfaceModules {
docs[key] = *mod
fmt.Println(key, mod.ParentModule)
parentMod := docs[mod.ParentModule]
parentMod.Interfaces[key] = *mod
}
var wg sync.WaitGroup
wg.Add(len(docs) * 2)
//var wg sync.WaitGroup
//wg.Add(len(docs) * 2)
for mod, v := range docs {
u, err := json.MarshalIndent(v, "", " ")
if err != nil {
panic(err)
}
fmt.Println(mod)
f, err := os.Create("defs/" + mod + ".json")
if err != nil {
panic(err)
}
f.WriteString(string(u))
}
//wg.Wait()
} else if os.Args[1] == "md" {
fmt.Println("Generating MD files from Hilbish doc defs!")
os.Mkdir("docs", 0777)
os.RemoveAll("docs/api")
os.Mkdir("docs/api", 0777)
f, err := os.Create("docs/api/_index.md")
if err != nil {
panic(err)
}
f.WriteString(`---
title: API
layout: doc
weight: -100
menu: docs
---
Welcome to the API documentation for Hilbish. This documents Lua functions
provided by Hilbish.
`)
f.Close()
defs, err := os.ReadDir("defs")
if err != nil {
panic(err)
}
for _, defEntry := range defs {
defContent, err := os.ReadFile(filepath.Join(".", "defs", defEntry.Name()))
if err != nil {
panic(err)
}
var def module
err = json.Unmarshal(defContent, &def)
if err != nil {
panic(err)
}
generateFile(def)
}
}
}
func generateFile(v module) {
mod := v.Name
docPath := "docs/api/" + mod + ".md"
if v.HasInterfaces {
os.Mkdir("docs/api/" + mod, 0777)
os.Mkdir("docs/api/"+mod, 0777)
os.Remove(docPath) // remove old doc path if it exists
docPath = "docs/api/" + mod + "/_index.md"
}
@ -472,18 +523,16 @@ provided by Hilbish.
docPath = "docs/api/" + v.ParentModule + "/" + mod + ".md"
}
go func(modname, docPath string, modu module) {
defer wg.Done()
modOrIface := "Module"
if modu.ParentModule != "" {
if v.ParentModule != "" {
modOrIface = "Module"
}
lastHeader := ""
f, _ := os.Create(docPath)
f.WriteString(fmt.Sprintf(header, modOrIface, modname, modu.ShortDescription))
f.WriteString(fmt.Sprintf(header, modOrIface, mod, v.ShortDescription))
typeTag, _ := regexp.Compile(`\B@\w+`)
modDescription := typeTag.ReplaceAllStringFunc(strings.Replace(strings.Replace(modu.Description, "<", `\<`, -1), "{{\\<", "{{<", -1), func(typ string) string {
/*modDescription := typeTag.ReplaceAllStringFunc(strings.Replace(strings.Replace(v.Description, "<", `\<`, -1), "{{\\<", "{{<", -1), func(typ string) string {
typName := typ[1:]
typLookup := typeTable[strings.ToLower(typName)]
ifaces := typLookup[0] + "." + typLookup[1] + "/"
@ -492,13 +541,14 @@ provided by Hilbish.
}
linkedTyp := fmt.Sprintf("/Hilbish/docs/api/%s/%s#%s", typLookup[0], ifaces, strings.ToLower(typName))
return fmt.Sprintf(`<a href="%s" style="text-decoration: none;">%s</a>`, linkedTyp, typName)
})
})*/
modDescription := v.Description
f.WriteString(heading("Introduction", 2))
f.WriteString(modDescription)
f.WriteString("\n\n")
if len(modu.Docs) != 0 {
if len(v.Docs) != 0 {
funcCount := 0
for _, dps := range modu.Docs {
for _, dps := range v.Docs {
if dps.IsMember {
continue
}
@ -506,18 +556,18 @@ provided by Hilbish.
}
f.WriteString(heading("Functions", 2))
lastHeader = "functions"
//lastHeader = "functions"
diff := 0
funcTable := [][]string{}
for _, dps := range modu.Docs {
for _, dps := range v.Docs {
if dps.IsMember {
diff++
continue
}
if len(dps.Doc) == 0 {
fmt.Printf("WARNING! Function %s on module %s has no documentation!\n", dps.FuncName, modname)
fmt.Printf("WARNING! Function %s on module %s has no documentation!\n", dps.FuncName, mod)
} else {
funcTable = append(funcTable, []string{fmt.Sprintf(`<a href="#%s">%s</a>`, dps.FuncName, dps.FuncSig), dps.Doc[0]})
}
@ -525,35 +575,36 @@ provided by Hilbish.
f.WriteString(table(funcTable))
}
if len(modu.Fields) != 0 {
if len(v.Fields) != 0 {
f.WriteString(heading("Static module fields", 2))
fieldsTable := [][]string{}
for _, dps := range modu.Fields {
for _, dps := range v.Fields {
fieldsTable = append(fieldsTable, []string{dps.FuncName, strings.Join(dps.Doc, " ")})
}
f.WriteString(table(fieldsTable))
}
if len(modu.Properties) != 0 {
if len(v.Properties) != 0 {
f.WriteString(heading("Object properties", 2))
propertiesTable := [][]string{}
for _, dps := range modu.Properties {
for _, dps := range v.Properties {
propertiesTable = append(propertiesTable, []string{dps.FuncName, strings.Join(dps.Doc, " ")})
}
f.WriteString(table(propertiesTable))
}
if len(modu.Docs) != 0 {
if len(v.Docs) != 0 {
if lastHeader != "functions" {
f.WriteString(heading("Functions", 2))
}
for _, dps := range modu.Docs {
for _, dps := range v.Docs {
if dps.IsMember {
continue
}
f.WriteString(fmt.Sprintf("<hr>\n<div id='%s'>", dps.FuncName))
htmlSig := typeTag.ReplaceAllStringFunc(strings.Replace(modname + "." + dps.FuncSig, "<", `\<`, -1), func(typ string) string {
f.WriteString("``` =html\n")
f.WriteString(fmt.Sprintf("<hr class='my-4 text-neutral-400 dark:text-neutral-600'>\n<div id='%s'>", dps.FuncName))
htmlSig := strings.Replace(mod+"."+dps.FuncSig, "<", `\<`, -1) /*typeTag.ReplaceAllStringFunc(strings.Replace(mod+"."+dps.FuncSig, "<", `\<`, -1), func(typ string) string {
typName := typ[1:]
typLookup := typeTable[strings.ToLower(typName)]
ifaces := typLookup[0] + "." + typLookup[1] + "/"
@ -562,9 +613,9 @@ provided by Hilbish.
}
linkedTyp := fmt.Sprintf("/Hilbish/docs/api/%s/%s#%s", typLookup[0], ifaces, strings.ToLower(typName))
return fmt.Sprintf(`<a href="%s" style="text-decoration: none;" id="lol">%s</a>`, linkedTyp, typName)
})
})*/
f.WriteString(fmt.Sprintf(`
<h4 class='heading'>
<h4 class='text-xl font-medium mb-2'>
%s
<a href="#%s" class='heading-link'>
<i class="fas fa-paperclip"></i>
@ -572,6 +623,8 @@ provided by Hilbish.
</h4>
`, htmlSig, dps.FuncName))
f.WriteString("```\n\n")
for _, doc := range dps.Doc {
if !strings.HasPrefix(doc, "---") && doc != "" {
f.WriteString(doc + " \n")
@ -590,7 +643,7 @@ provided by Hilbish.
typ = p.Type[3:]
}
f.WriteString(fmt.Sprintf("`%s` *`%s`*", typ, p.Name))
f.WriteString(fmt.Sprintf("`%s` `*%s*`", typ, p.Name))
if isVariadic {
f.WriteString(" (This type is variadic. You can pass an infinite amount of parameters with this type.)")
}
@ -600,17 +653,16 @@ provided by Hilbish.
}
if codeExample := dps.Tags["example"]; codeExample != nil {
f.WriteString(heading("Example", 4))
f.WriteString(fmt.Sprintf("```lua\n%s\n```\n", strings.Join(codeExample[0].fields, "\n")))
f.WriteString(fmt.Sprintf("```lua\n%s\n```\n", strings.Join(codeExample[0].Fields, "\n")))
}
f.WriteString("</div>")
f.WriteString("\n\n")
}
}
if len(modu.Types) != 0 {
if len(v.Types) != 0 {
f.WriteString(heading("Types", 2))
for _, dps := range modu.Types {
f.WriteString("<hr>\n\n")
for _, dps := range v.Types {
f.WriteString("``` =html\n<hr class='my-4 text-neutral-400 dark:text-neutral-600'>\n```\n\n")
f.WriteString(heading(dps.FuncName, 2))
for _, doc := range dps.Doc {
if !strings.HasPrefix(doc, "---") {
@ -621,14 +673,14 @@ provided by Hilbish.
f.WriteString(heading("Object Properties", 2))
propertiesTable := [][]string{}
for _, dps := range modu.Properties {
for _, dps := range v.Properties {
propertiesTable = append(propertiesTable, []string{dps.FuncName, strings.Join(dps.Doc, " ")})
}
f.WriteString(table(propertiesTable))
}
f.WriteString("\n")
f.WriteString(heading("Methods", 3))
for _, dps := range modu.Docs {
for _, dps := range v.Docs {
if !dps.IsMember {
continue
}
@ -636,7 +688,7 @@ provided by Hilbish.
typName := regexp.MustCompile(`\w+`).FindString(typ[1:])
typLookup := typeTable[strings.ToLower(typName)]
fmt.Printf("%+q, \n", typLookup)
linkedTyp := fmt.Sprintf("/Hilbish/docs/api/%s/%s/#%s", typLookup[0], typLookup[0] + "." + typLookup[1], strings.ToLower(typName))
linkedTyp := fmt.Sprintf("/Hilbish/docs/api/%s/%s/#%s", typLookup[0], typLookup[0]+"."+typLookup[1], strings.ToLower(typName))
return fmt.Sprintf(`<a href="#%s" style="text-decoration: none;">%s</a>`, linkedTyp, typName)
})
//f.WriteString(fmt.Sprintf("#### %s\n", htmlSig))
@ -650,43 +702,6 @@ provided by Hilbish.
}
}
}
}(mod, docPath, v)
go func(md, modname string, modu module) {
defer wg.Done()
if modu.ParentModule != "" {
return
}
ff, _ := os.Create("emmyLuaDocs/" + modname + ".lua")
ff.WriteString("--- @meta\n\nlocal " + modname + " = {}\n\n")
for _, em := range emmyDocs[modname] {
if strings.HasSuffix(em.DocPiece.GoFuncName, strings.ToLower("loader")) {
continue
}
dps := em.DocPiece
funcdocs := dps.Doc
ff.WriteString("--- " + strings.Join(funcdocs, "\n--- ") + "\n")
if len(em.Annotations) != 0 {
ff.WriteString(strings.Join(em.Annotations, "\n") + "\n")
}
accessor := "."
if dps.IsMember {
accessor = ":"
}
signature := strings.Split(dps.FuncSig, " ->")[0]
var intrface string
if dps.IsInterface {
intrface = "." + dps.Interfacing
}
ff.WriteString("function " + modname + intrface + accessor + signature + " end\n\n")
}
ff.WriteString("return " + modname + "\n")
}(mod, mod, v)
}
wg.Wait()
}
func heading(name string, level int) string {
@ -696,13 +711,13 @@ func heading(name string, level int) string {
func table(elems [][]string) string {
var b strings.Builder
b.WriteString("``` =html\n")
b.WriteString("<div class='p-2 rounded'>\n")
b.WriteString("<table class='w-full'>\n")
b.WriteString("<div class='relative overflow-x-auto sm:rounded-lg my-4'>\n")
b.WriteString("<table class='w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400'>\n")
b.WriteString("<tbody>\n")
for _, line := range elems {
b.WriteString("<tr class='m-2 bg-neutral-700'>\n")
b.WriteString("<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>\n")
for _, col := range line {
b.WriteString("<td>")
b.WriteString("<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>")
b.WriteString(col)
b.WriteString("</td>\n")
}

View File

@ -110,7 +110,7 @@ menu:
]]
for iface, dps in pairs(pieces) do
local mod = iface:match '(%w+)%.' or 'nature'
local mod = iface ~= 'nature' and iface:match '(%w+)' or 'nature'
local docParent = 'Nature'
path = string.format('docs/%s/%s.md', mod, iface)
@ -128,100 +128,21 @@ for iface, dps in pairs(pieces) do
local exists = pcall(fs.stat, path)
local newOrNotNature = (exists and mod ~= 'nature') or iface == 'hilbish'
local f <close> = io.open(path, newOrNotNature and 'r+' or 'w+')
local tocPos
--local f <close> = io.open(path, newOrNotNature and 'r+' or 'w+')
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
table.remove(descriptions[iface], 1)
f:write(string.format('\n## Introduction\n%s\n\n', table.concat(descriptions[iface], '\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
--f:write(string.format('\n## Introduction\n%s\n\n', table.concat(descriptions[iface], '\n')))
--f:write('## Functions\n')
end
end
print(mod, dps)
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 docs = piece[2]
local sig = string.format('%s.%s(', iface, func)
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
print(func, docs)
end]]
end

388
defs/bait.json Normal file
View File

@ -0,0 +1,388 @@
{
"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
}
]
}
}
]
}

152
defs/commander.json Normal file
View File

@ -0,0 +1,152 @@
{
"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 Normal file
View File

@ -0,0 +1,549 @@
{
"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 Normal file

File diff suppressed because it is too large Load Diff

140
defs/snail.json Normal file
View File

@ -0,0 +1,140 @@
{
"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
}
]
}
}
]
}

54
defs/terminal.json Normal file
View File

@ -0,0 +1,54 @@
{
"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
}
]
}

View File

@ -9,6 +9,7 @@ menu:
## Introduction
Bait is the event emitter for Hilbish. Much like Node.js and
its `events` system, many actions in Hilbish emit events.
Unlike Node.js, Hilbish events are global. So make sure to
@ -33,98 +34,140 @@ What this does is, whenever the `command.exit` event is thrown,
this function will set the user prompt.
## 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`.|
<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'><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'>
<h4 class='heading'>
<h4 class='text-xl font-medium mb-2'>
bait.catch(name, cb)
<a href="#catch" class='heading-link'>
<i class="fas fa-paperclip"></i>
</a>
</h4>
```
Catches an event. This function can be used to act on events.
#### Parameters
`string` **`name`**
`string` `*name*`
The name of the hook.
`function` **`cb`**
`function` `*cb*`
The function that will be called when the hook is thrown.
#### Example
```lua
bait.catch('hilbish.exit', function()
print 'Goodbye Hilbish!'
end)
```
</div>
<hr>
``` =html
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
<div id='catchOnce'>
<h4 class='heading'>
<h4 class='text-xl font-medium mb-2'>
bait.catchOnce(name, cb)
<a href="#catchOnce" class='heading-link'>
<i class="fas fa-paperclip"></i>
</a>
</h4>
```
Catches an event, but only once. This will remove the hook immediately after it runs for the first time.
#### Parameters
`string` **`name`**
`string` `*name*`
The name of the event
`function` **`cb`**
`function` `*cb*`
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'>
<h4 class='heading'>
<h4 class='text-xl font-medium mb-2'>
bait.hooks(name) -> table
<a href="#hooks" class='heading-link'>
<i class="fas fa-paperclip"></i>
</a>
</h4>
```
Returns a table of functions that are hooked on an event with the corresponding `name`.
#### Parameters
`string` **`name`**
`string` `*name*`
The name of the hook
</div>
<hr>
``` =html
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
<div id='release'>
<h4 class='heading'>
<h4 class='text-xl font-medium mb-2'>
bait.release(name, catcher)
<a href="#release" class='heading-link'>
<i class="fas fa-paperclip"></i>
</a>
</h4>
```
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.
#### Parameters
`string` **`name`**
`string` `*name*`
Name of the event the hook is on
`function` **`catcher`**
`function` `*catcher*`
Hook function to remove
#### Example
```lua
local hookCallback = function() print 'hi' end
@ -134,27 +177,32 @@ bait.catch('event', hookCallback)
bait.release('event', hookCallback)
-- 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'>
<h4 class='heading'>
<h4 class='text-xl font-medium mb-2'>
bait.throw(name, ...args)
<a href="#throw" class='heading-link'>
<i class="fas fa-paperclip"></i>
</a>
</h4>
```
Throws a hook with `name` with the provided `args`.
#### Parameters
`string` **`name`**
`string` `*name*`
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.
#### Example
```lua
bait.throw('greeting', 'world')
@ -163,5 +211,5 @@ bait.catch('gretting', function(greetTo)
print('Hello ' .. greetTo)
end)
```
</div>

View File

@ -9,6 +9,7 @@ menu:
## Introduction
Commander is the library which handles Hilbish commands. This makes
the user able to add Lua-written commands to their shell without making
a separate script in a bin folder. Instead, you may simply use the Commander
@ -29,7 +30,7 @@ have is: What is the `sinks` parameter?
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']`)
as `in` is also a Lua keyword, so `input` is preferred for use.
All of them are a <a href="/Hilbish/docs/api/hilbish/#sink" style="text-decoration: none;">Sink</a>.
All of them are a @Sink.
In the future, `sinks.in` will be removed.
- `in` is the standard input.
@ -40,49 +41,76 @@ This is usually where command output should go.
This sink is for writing errors, as the name would suggest.
## 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:|
<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'><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'>
<h4 class='heading'>
<h4 class='text-xl font-medium mb-2'>
commander.deregister(name)
<a href="#deregister" class='heading-link'>
<i class="fas fa-paperclip"></i>
</a>
</h4>
```
Removes the named command. Note that this will only remove Commander-registered commands.
#### Parameters
`string` **`name`**
`string` `*name*`
Name of the command to remove.
</div>
<hr>
``` =html
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
<div id='register'>
<h4 class='heading'>
<h4 class='text-xl font-medium mb-2'>
commander.register(name, cb)
<a href="#register" class='heading-link'>
<i class="fas fa-paperclip"></i>
</a>
</h4>
```
Adds a new command with the given `name`. When Hilbish has to run a command with a name,
it will run the function providing the arguments and sinks.
#### Parameters
`string` **`name`**
`string` `*name*`
Name of the command
`function` **`cb`**
`function` `*cb*`
Callback to handle command invocation
#### Example
```lua
-- 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'
@ -93,21 +121,25 @@ commander.register('hello', function(args, sinks)
sinks.out:writeln('Hello ' .. name)
end)
```
</div>
<hr>
``` =html
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
<div id='registry'>
<h4 class='heading'>
<h4 class='text-xl font-medium mb-2'>
commander.registry() -> table
<a href="#registry" class='heading-link'>
<i class="fas fa-paperclip"></i>
</a>
</h4>
```
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.
#### Parameters
This function has no parameters.
</div>
This function has no parameters.

View File

@ -9,117 +9,188 @@ menu:
## Introduction
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 offers more functions and will work on any operating system Hilbish does.
## Functions
|||
|----|----|
|<a href="#abs">abs(path) -> string</a>|Returns an absolute version of the `path`.|
|<a href="#basename">basename(path) -> string</a>|Returns the "basename," or the last part of the provided `path`. If path is empty,|
|<a href="#cd">cd(dir)</a>|Changes Hilbish's directory to `dir`.|
|<a href="#dir">dir(path) -> string</a>|Returns the directory part of `path`. If a file path like|
|<a href="#glob">glob(pattern) -> matches (table)</a>|Match all files based on the provided `pattern`.|
|<a href="#join">join(...path) -> string</a>|Takes any list of paths and joins them based on the operating system's path separator.|
|<a href="#mkdir">mkdir(name, recursive)</a>|Creates a new directory with the provided `name`.|
|<a href="#pipe">fpipe() -> File, File</a>|Returns a pair of connected files, also known as a pipe.|
|<a href="#readdir">readdir(path) -> table[string]</a>|Returns a list of all files and directories in the provided path.|
|<a href="#stat">stat(path) -> {}</a>|Returns the information about a given `path`.|
``` =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'><a href="#abs">abs(path) -> string</a></td>
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Returns an absolute version of the `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="#basename">basename(path) -> string</a></td>
<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>
</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
|||
|----|----|
|pathSep|The operating system's path separator.|
<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'>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'>
<h4 class='heading'>
<h4 class='text-xl font-medium mb-2'>
fs.abs(path) -> string
<a href="#abs" class='heading-link'>
<i class="fas fa-paperclip"></i>
</a>
</h4>
```
Returns an absolute version of the `path`.
This can be used to resolve short paths like `..` to `/home/user`.
#### Parameters
`string` **`path`**
`string` `*path*`
</div>
<hr>
``` =html
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
<div id='basename'>
<h4 class='heading'>
<h4 class='text-xl font-medium mb-2'>
fs.basename(path) -> string
<a href="#basename" class='heading-link'>
<i class="fas fa-paperclip"></i>
</a>
</h4>
```
Returns the "basename," or the last part of the provided `path`. If path is empty,
`.` will be returned.
#### Parameters
`string` **`path`**
`string` `*path*`
Path to get the base name of.
</div>
<hr>
``` =html
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
<div id='cd'>
<h4 class='heading'>
<h4 class='text-xl font-medium mb-2'>
fs.cd(dir)
<a href="#cd" class='heading-link'>
<i class="fas fa-paperclip"></i>
</a>
</h4>
```
Changes Hilbish's directory to `dir`.
#### Parameters
`string` **`dir`**
`string` `*dir*`
Path to change directory to.
</div>
<hr>
``` =html
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
<div id='dir'>
<h4 class='heading'>
<h4 class='text-xl font-medium mb-2'>
fs.dir(path) -> string
<a href="#dir" class='heading-link'>
<i class="fas fa-paperclip"></i>
</a>
</h4>
```
Returns the directory part of `path`. If a file path like
`~/Documents/doc.txt` then this function will return `~/Documents`.
#### Parameters
`string` **`path`**
`string` `*path*`
Path to get the directory for.
</div>
<hr>
``` =html
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
<div id='glob'>
<h4 class='heading'>
<h4 class='text-xl font-medium mb-2'>
fs.glob(pattern) -> matches (table)
<a href="#glob" class='heading-link'>
<i class="fas fa-paperclip"></i>
</a>
</h4>
```
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
#### Parameters
`string` **`pattern`**
`string` `*pattern*`
Pattern to compare files with.
#### Example
```lua
--[[
Within a folder that contains the following files:
@ -132,100 +203,121 @@ local matches = fs.glob './*.lua'
print(matches)
-- -> {'init.lua', 'code.lua'}
```
</div>
<hr>
``` =html
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
<div id='join'>
<h4 class='heading'>
<h4 class='text-xl font-medium mb-2'>
fs.join(...path) -> string
<a href="#join" class='heading-link'>
<i class="fas fa-paperclip"></i>
</a>
</h4>
```
Takes any list of paths and joins them based on the operating system's path separator.
#### 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
#### Example
```lua
-- This prints the directory for Hilbish's config!
print(fs.join(hilbish.userDir.config, 'hilbish'))
-- -> '/home/user/.config/hilbish' on Linux
```
</div>
<hr>
``` =html
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
<div id='mkdir'>
<h4 class='heading'>
<h4 class='text-xl font-medium mb-2'>
fs.mkdir(name, recursive)
<a href="#mkdir" class='heading-link'>
<i class="fas fa-paperclip"></i>
</a>
</h4>
```
Creates a new directory with the provided `name`.
With `recursive`, mkdir will create parent directories.
#### Parameters
`string` **`name`**
`string` `*name*`
Name of the directory
`boolean` **`recursive`**
`boolean` `*recursive*`
Whether to create parent directories for the provided name
#### Example
```lua
-- 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)
```
</div>
<hr>
``` =html
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
<div id='pipe'>
<h4 class='heading'>
<h4 class='text-xl font-medium mb-2'>
fs.fpipe() -> File, File
<a href="#pipe" class='heading-link'>
<i class="fas fa-paperclip"></i>
</a>
</h4>
```
Returns a pair of connected files, also known as a pipe.
The type returned is a Lua file, same as returned from `io` functions.
#### Parameters
This function has no parameters.
</div>
<hr>
This function has no parameters.
``` =html
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
<div id='readdir'>
<h4 class='heading'>
<h4 class='text-xl font-medium mb-2'>
fs.readdir(path) -> table[string]
<a href="#readdir" class='heading-link'>
<i class="fas fa-paperclip"></i>
</a>
</h4>
```
Returns a list of all files and directories in the provided path.
#### Parameters
`string` **`dir`**
`string` `*dir*`
</div>
<hr>
``` =html
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
<div id='stat'>
<h4 class='heading'>
<h4 class='text-xl font-medium mb-2'>
fs.stat(path) -> {}
<a href="#stat" class='heading-link'>
<i class="fas fa-paperclip"></i>
</a>
</h4>
```
Returns the information about a given `path`.
The returned table contains the following values:
name (string) - Name of the path
@ -234,10 +326,12 @@ mode (string) - Unix permission mode in an octal format string (with leading 0)
isDir (boolean) - If the path is a directory
#### Parameters
`string` **`path`**
`string` `*path*`
#### Example
```lua
local inspect = require 'inspect'
@ -253,5 +347,5 @@ Would print the following:
}
]]--
```
</div>

View File

@ -1,6 +1,6 @@
---
title: Module hilbish
description:
description: the core Hilbish API
layout: doc
menu:
docs:
@ -9,100 +9,153 @@ menu:
## Introduction
The Hilbish module includes the core API, containing
interfaces and functions which directly relate to shell functionality.
## Functions
``` =html
<div class='p-2 rounded'>
<table class='w-full'>
<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='m-2 bg-neutral-700'>
<td><a href="#alias">alias(cmd, orig)</a></td>
<td>Sets an alias, with a name of `cmd` to another command.</td>
<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="#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>
</tr>
<tr class='m-2 bg-neutral-700'>
<td><a href="#appendPath">appendPath(dir)</a></td>
<td>Appends the provided dir to the command path (`$PATH`)</td>
<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="#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>
</tr>
<tr class='m-2 bg-neutral-700'>
<td><a href="#complete">complete(scope, cb)</a></td>
<td>Registers a completion handler for the specified scope.</td>
<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="#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>
</tr>
<tr class='m-2 bg-neutral-700'>
<td><a href="#cwd">cwd() -> string</a></td>
<td>Returns the current directory of the shell.</td>
<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="#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>
</tr>
<tr class='m-2 bg-neutral-700'>
<td><a href="#exec">exec(cmd)</a></td>
<td>Replaces the currently running Hilbish instance with the supplied command.</td>
<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="#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>
</tr>
<tr class='m-2 bg-neutral-700'>
<td><a href="#goro">goro(fn)</a></td>
<td>Puts `fn` in a Goroutine.</td>
<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="#goro">goro(fn)</a></td>
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Puts `fn` in a Goroutine.</td>
</tr>
<tr class='m-2 bg-neutral-700'>
<td><a href="#highlighter">highlighter(line)</a></td>
<td>Line highlighter handler.</td>
<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="#highlighter">highlighter(line)</a></td>
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Line highlighter handler.</td>
</tr>
<tr class='m-2 bg-neutral-700'>
<td><a href="#hinter">hinter(line, pos)</a></td>
<td>The command line hint handler. It gets called on every key insert to</td>
<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="#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>
</tr>
<tr class='m-2 bg-neutral-700'>
<td><a href="#inputMode">inputMode(mode)</a></td>
<td>Sets the input mode for Hilbish's line reader.</td>
<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="#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>
</tr>
<tr class='m-2 bg-neutral-700'>
<td><a href="#interval">interval(cb, time) -> @Timer</a></td>
<td>Runs the `cb` function every specified amount of `time`.</td>
<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="#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>
</tr>
<tr class='m-2 bg-neutral-700'>
<td><a href="#multiprompt">multiprompt(str)</a></td>
<td>Changes the text prompt when Hilbish asks for more input.</td>
<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="#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>
</tr>
<tr class='m-2 bg-neutral-700'>
<td><a href="#prependPath">prependPath(dir)</a></td>
<td>Prepends `dir` to $PATH.</td>
<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="#prependPath">prependPath(dir)</a></td>
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Prepends `dir` to $PATH.</td>
</tr>
<tr class='m-2 bg-neutral-700'>
<td><a href="#prompt">prompt(str, typ)</a></td>
<td>Changes the shell prompt to the provided string.</td>
<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="#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>
</tr>
<tr class='m-2 bg-neutral-700'>
<td><a href="#read">read(prompt) -> input (string)</a></td>
<td>Read input from the user, using Hilbish's line editor/input reader.</td>
<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="#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>
</tr>
<tr class='m-2 bg-neutral-700'>
<td><a href="#timeout">timeout(cb, time) -> @Timer</a></td>
<td>Executed the `cb` function after a period of `time`.</td>
<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="#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>
</tr>
<tr class='m-2 bg-neutral-700'>
<td><a href="#which">which(name) -> string</a></td>
<td>Checks if `name` is a valid command.</td>
<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="#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>
</tr>
</tbody>
</table>
</div>
```
<hr>
## Static module fields
``` =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'>
<h4 class='heading'>
<h4 class='text-xl font-medium mb-2'>
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`*
`string` `*cmd*`
Name of the alias
`string` *`orig`*
`string` `*orig*`
Command that will be aliased
#### Example
@ -115,22 +168,25 @@ hilbish.alias('ga', 'git add')
hilbish.alias('dircount', 'ls %1 | wc -l')
-- "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'>
<h4 class='heading'>
<h4 class='text-xl font-medium mb-2'>
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`*
`string|table` `*dir*`
Directory (or directories) to append to path
#### Example
@ -145,17 +201,20 @@ hilbish.appendPath {
'~/.local/bin'
}
```
</div>
<hr>
``` =html
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
<div id='complete'>
<h4 class='heading'>
<h4 class='text-xl font-medium mb-2'>
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`).
@ -164,10 +223,10 @@ provides more details.
#### Parameters
`string` *`scope`*
`string` `*scope*`
`function` *`cb`*
`function` `*cb*`
#### Example
@ -197,52 +256,61 @@ hilbish.complete('command.sudo', function(query, ctx, fields)
return {compGroup}, pfx
end)
```
</div>
<hr>
``` =html
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
<div id='cwd'>
<h4 class='heading'>
<h4 class='text-xl font-medium mb-2'>
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>
``` =html
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
<div id='exec'>
<h4 class='heading'>
<h4 class='text-xl font-medium mb-2'>
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`*
`string` `*cmd*`
</div>
<hr>
``` =html
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
<div id='goro'>
<h4 class='heading'>
<h4 class='text-xl font-medium mb-2'>
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.**
@ -250,20 +318,23 @@ This can be used to run any function in another thread at the same time as other
#### Parameters
`function` *`fn`*
`function` `*fn*`
</div>
<hr>
``` =html
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
<div id='highlighter'>
<h4 class='heading'>
<h4 class='text-xl font-medium mb-2'>
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
@ -272,7 +343,7 @@ Note that to set a highlighter, one has to override this function.
#### Parameters
`string` *`line`*
`string` `*line*`
#### Example
@ -283,17 +354,20 @@ function hilbish.highlighter(line)
return line:gsub('"%w+"', function(c) return lunacolors.green(c) end)
end
```
</div>
<hr>
``` =html
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
<div id='hinter'>
<h4 class='heading'>
<h4 class='text-xl font-medium mb-2'>
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
@ -302,10 +376,10 @@ override this function with your custom handler.
#### Parameters
`string` *`line`*
`string` `*line*`
`number` *`pos`*
`number` `*pos*`
Position of cursor in line. Usually equals string.len(line)
#### Example
@ -316,65 +390,74 @@ function hilbish.hinter(line, pos)
return 'hi'
end
```
</div>
<hr>
``` =html
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
<div id='inputMode'>
<h4 class='heading'>
<h4 class='text-xl font-medium mb-2'>
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`*
`string` `*mode*`
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'>
<h4 class='heading'>
hilbish.interval(cb, time) -> <a href="/Hilbish/docs/api/hilbish/hilbish.timers/#timer" style="text-decoration: none;" id="lol">Timer</a>
<h4 class='text-xl font-medium mb-2'>
hilbish.interval(cb, time) -> @Timer
<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`*
`function` `*cb*`
`number` *`time`*
`number` `*time*`
Time in milliseconds.
</div>
<hr>
``` =html
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
<div id='multiprompt'>
<h4 class='heading'>
<h4 class='text-xl font-medium mb-2'>
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`*
`string` `*str*`
#### Example
@ -396,35 +479,41 @@ hey ...!
]]--
hilbish.multiprompt '-->'
```
</div>
<hr>
``` =html
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
<div id='prependPath'>
<h4 class='heading'>
<h4 class='text-xl font-medium mb-2'>
hilbish.prependPath(dir)
<a href="#prependPath" class='heading-link'>
<i class="fas fa-paperclip"></i>
</a>
</h4>
```
Prepends `dir` to $PATH.
#### Parameters
`string` *`dir`*
`string` `*dir*`
</div>
<hr>
``` =html
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
<div id='prompt'>
<h4 class='heading'>
<h4 class='text-xl font-medium mb-2'>
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.
@ -434,10 +523,10 @@ These will be formatted and replaced with the appropriate values.
#### Parameters
`string` *`str`*
`string` `*str*`
`string` *`typ?`*
`string` `*typ?*`
Type of prompt, being left or right. Left by default.
#### Example
@ -449,72 +538,83 @@ hilbish.prompt '%u %d ∆'
hilbish.prompt '%u@%h :%d $'
-- prompt: user@hostname: ~/directory $
```
</div>
<hr>
``` =html
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
<div id='read'>
<h4 class='heading'>
<h4 class='text-xl font-medium mb-2'>
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?`*
`string` `*prompt?*`
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'>
<h4 class='heading'>
hilbish.timeout(cb, time) -> <a href="/Hilbish/docs/api/hilbish/hilbish.timers/#timer" style="text-decoration: none;" id="lol">Timer</a>
<h4 class='text-xl font-medium mb-2'>
hilbish.timeout(cb, time) -> @Timer
<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`*
`function` `*cb*`
`number` *`time`*
`number` `*time*`
Time to run in milliseconds.
</div>
<hr>
``` =html
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
<div id='which'>
<h4 class='heading'>
<h4 class='text-xl font-medium mb-2'>
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`*
`string` `*name*`
</div>
## Types
<hr>
``` =html
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
```
## Sink

View File

@ -1,539 +0,0 @@
---
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>

View File

@ -1,67 +0,0 @@
---
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>

View File

@ -1,91 +0,0 @@
---
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>

View File

@ -1,149 +0,0 @@
---
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>

View File

@ -1,124 +0,0 @@
---
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>

View File

@ -1,102 +0,0 @@
---
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>

View File

@ -1,146 +0,0 @@
---
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.

View File

@ -1,135 +0,0 @@
---
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>

View File

@ -1,73 +0,0 @@
---
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>

View File

@ -1,20 +0,0 @@
---
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|

View File

@ -1,247 +0,0 @@
---
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>

View File

@ -1,100 +0,0 @@
---
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.

View File

@ -1,20 +0,0 @@
---
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|

View File

@ -9,42 +9,66 @@ menu:
## Introduction
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
Hilbish functions.
## Functions
|||
|----|----|
|<a href="#new">new() -> @Snail</a>|Creates a new Snail instance.|
<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'><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'>
<h4 class='heading'>
snail.new() -> <a href="/Hilbish/docs/api/snail/#snail" style="text-decoration: none;" id="lol">Snail</a>
<h4 class='text-xl font-medium mb-2'>
snail.new() -> @Snail
<a href="#new" class='heading-link'>
<i class="fas fa-paperclip"></i>
</a>
</h4>
```
Creates a new Snail instance.
#### Parameters
This function has no parameters.
</div>
## Types
<hr>
``` =html
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
```
## Snail
A Snail is a shell script interpreter instance.
### Methods
#### dir(path)
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.
#### run(command, streams)
Runs a shell command. Works the same as `hilbish.run`, but only accepts a table of streams.

View File

@ -8,74 +8,112 @@ menu:
---
## Introduction
The terminal library is a simple and lower level library for certain terminal interactions.
## 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`|
<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'><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'>
<h4 class='heading'>
<h4 class='text-xl font-medium mb-2'>
terminal.restoreState()
<a href="#restoreState" class='heading-link'>
<i class="fas fa-paperclip"></i>
</a>
</h4>
```
Restores the last saved state of the terminal
#### Parameters
This function has no parameters.
</div>
<hr>
This function has no parameters.
``` =html
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
<div id='saveState'>
<h4 class='heading'>
<h4 class='text-xl font-medium mb-2'>
terminal.saveState()
<a href="#saveState" class='heading-link'>
<i class="fas fa-paperclip"></i>
</a>
</h4>
```
Saves the current state of the terminal.
#### Parameters
This function has no parameters.
</div>
<hr>
This function has no parameters.
``` =html
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
<div id='setRaw'>
<h4 class='heading'>
<h4 class='text-xl font-medium mb-2'>
terminal.setRaw()
<a href="#setRaw" class='heading-link'>
<i class="fas fa-paperclip"></i>
</a>
</h4>
```
Puts the terminal into raw mode.
#### Parameters
This function has no parameters.
</div>
<hr>
This function has no parameters.
``` =html
<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
<div id='size'>
<h4 class='heading'>
<h4 class='text-xl font-medium mb-2'>
terminal.size()
<a href="#size" class='heading-link'>
<i class="fas fa-paperclip"></i>
</a>
</h4>
```
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.
#### Parameters
This function has no parameters.
</div>
This function has no parameters.

View File

@ -1,28 +0,0 @@
--- @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

View File

@ -1,18 +0,0 @@
--- @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

View File

@ -1,54 +0,0 @@
--- @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

View File

@ -1,240 +0,0 @@
--- @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

View File

@ -1,16 +0,0 @@
--- @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

View File

@ -1,18 +0,0 @@
--- @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

View File

@ -1,83 +0,0 @@
--- @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

View File

@ -5,56 +5,45 @@ layout: page
---
## Official Binaries
The best way to get Hilbish is to get a build directly from GitHub.
At any time, there are 2 versions of Hilbish recommended for download:
At any time, there are 2 versions of Hilbish available to install:
the latest stable release, and development builds from the master branch.
You can download both at any time, but note that the development builds may
have breaking changes.
For the latest **stable release**, check here: https://github.com/Rosettea/Hilbish/releases/latest
For a **development build**: https://nightly.link/Rosettea/Hilbish/workflows/build/master
For the latest *stable release*, check here: https://github.com/Rosettea/Hilbish/releases/latest
For a *development build*: https://nightly.link/Rosettea/Hilbish/workflows/build/master
## Compiling
To read the steps for compiling Hilbish, head over to the [GitHub repository.](https://github.com/Rosettea/Hilbish#build)
## Package Repositories
Methods of installing Hilbish for your Linux distro.
### Fedora (COPR)
An official COPR is offered to install Hilbish easily on Fedora.
Enable the repo:
```
sudo dnf copr enable sammyette/Hilbish
```
Enable the repo: `dnf copr enable sammyette/Hilbish`
And install Hilbish:
```
sudo dnf install hilbish
```
And install Hilbish: `dnf install hilbish`
Or for the latest development build from master:
```
sudo dnf install hilbish-git
```
Or for the latest development build from master: `dnf install hilbish-git`
### Arch Linux (AUR)
Hilbish is on the AUR. Setup an AUR helper, and install.
Example with yay:
```
yay -S hilbish
```
Example with yay: `yay -S hilbish`
Or, from master branch:
```
yay -S hilbish-git
```
Or, from master branch: `yay -S hilbish-git`
### Alpine Linux
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`

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,17 @@
{
"dependencies": {
"@djot/djot": "^0.3.2",
"@tailwindcss/cli": "^4.1.4",
"tailwindcss": "^4.1.4"
"@tailwindcss/cli": "^4.1.10",
"npm-watch": "^0.13.0",
"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"
}
}

View File

@ -1,4 +1,4 @@
pub const base_url = ""
pub const base_url = "http://localhost:9080"
pub fn base_url_join(cont: String) -> String {
base_url <> "/" <> cont

View File

@ -11,37 +11,77 @@ import jot
import post
pub fn page(p: post.Post, doc_pages_list) -> element.Element(a) {
html.div([attribute.class("flex flex-col")], [
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")], [
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.div([attribute.class("flex-auto flex flex-col overflow-none")], [
html.div(
[
attribute.class(
"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.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("h-full sm:flex grid")], [
html.input([
attribute.type_("checkbox"),
attribute.id("sidebar-toggle"),
attribute.class("peer hidden"),
]),
html.span([], [element.text(p.title)])
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.div([attribute.class("grid")], [
html.input([attribute.type_("checkbox"), attribute.id("sidebar-toggle"), attribute.class("peer hidden")]),
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")], [
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)) {
html.li([attribute.class("mb-2")], [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),
]),
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)]),
// 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) {
let renderer = djot.Renderer(
let renderer =
djot.Renderer(
..djot.default_renderer(),
heading: fn(attrs, level, content) {
let size = case level {
@ -50,7 +90,12 @@ fn render_doc(md: String) {
3 -> "text-2xl"
_ -> "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 {
1 -> html.h1(to_attr(attr), content)
@ -58,7 +103,12 @@ fn render_doc(md: String) {
3 -> html.h3(to_attr(attr), content)
_ -> html.p(to_attr(attr), content)
}
}
},
code: fn(content) {
html.code([attribute.class("text-violet-600 dark:text-violet-400")], [
element.text(content),
])
},
)
djot.render(md, renderer)
}
@ -71,7 +121,8 @@ fn to_attr(attrs) {
fn render_doc_(md: String) -> String {
// w-full m-2 p-2 bg-neutral-700
let doc = jot.parse(md)
let updated_content = list.map(doc.content, fn(container) {
let updated_content =
list.map(doc.content, fn(container) {
case container {
jot.Heading(attributes, level, content) -> {
let size = case level {
@ -91,35 +142,6 @@ fn render_doc_(md: String) -> String {
jot.document_to_html(jot.Document(
content: updated_content,
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))
])
])
])
}

View File

@ -1,31 +1,39 @@
import gleam/option
import gleam/dict
import gleam/io
import gleam/order
import gleam/list
import gleam/option
import gleam/order
import gleam/string
import glaml
import lustre/attribute
import lustre/element
import lustre/element/html
import lustre/ssg
import lustre/ssg/djot
import tom
import simplifile
import glaml
import tom
import conf
import post
import pages/index
import pages/doc
import pages/index
import post
pub fn main() {
let assert Ok(files) = simplifile.get_files("./content")
let posts = list.map(files, fn(path: String) {
let posts =
list.map(files, fn(path: String) {
let assert Ok(ext) = path |> string.split(".") |> list.last
let slug = path |> string.replace("./content", "") |> string.drop_end({ext |> string.length()} + 1)
let slug =
path
|> string.replace("./content", "")
|> string.drop_end({ ext |> string.length() } + 1)
let assert Ok(name) = slug |> string.split("/") |> list.last
let slug = case name {
"_index" -> slug |> string.drop_end({ "_index" |> string.length() } + 1)
_ -> slug
}
let assert Ok(content) = simplifile.read(path)
let frontmatter = djot.frontmatter(content)
let metadata = case frontmatter {
@ -43,7 +51,6 @@ pub fn main() {
Ok(glaml.NodeStr(s)) -> s
_ -> ""
}
}
option.None -> ""
}
@ -52,35 +59,51 @@ pub fn main() {
#(slug, post.Post(name, title, slug, metadata, content))
})
let doc_pages = list.filter(posts, fn(page) {
let doc_pages =
list.filter(posts, fn(page) {
let isdoc = is_doc_page(page.0)
//io.debug(page.0)
//io.debug(isdoc)
isdoc
}) |> list.filter(fn(page) {
case page.1.metadata {
})
|> list.filter(fn(page) {
case { page.1 }.metadata {
option.Some(_) -> True
option.None -> False
}
}) |> list.sort(fn(p1, p2) {
})
|> list.sort(fn(p1, p2) {
//io.debug(p1)
//io.debug(p2)
let assert option.Some(p1_metadata) = p1.1.metadata
let p1_weight = case glaml.select_sugar(glaml.document_root(p1_metadata), "weight") {
let assert option.Some(p1_metadata) = { p1.1 }.metadata
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 p2_weight = case glaml.select_sugar(glaml.document_root(p2_metadata), "weight") {
let assert option.Some(p2_metadata) = { p2.1 }.metadata
let p2_weight = case
glaml.select_sugar(glaml.document_root(p2_metadata), "weight")
{
Ok(glaml.NodeInt(w)) -> w
_ -> 0
}
case p1_weight == 0 {
True -> {
case p1_weight == 0 {
True -> order.Eq
False ->
case p1_weight > p2_weight {
True -> order.Lt
False -> order.Gt
}
}
}
False -> {
case p1_weight < p2_weight {
case p1_weight > p2_weight {
True -> order.Lt
False -> order.Gt
}
@ -88,16 +111,16 @@ pub fn main() {
}
})
let build = ssg.new("./public")
let build =
ssg.new("./public")
|> ssg.add_static_dir("static")
|> ssg.add_static_route("/", create_page(index.page()))
|> 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())
_ -> post.0
}
let page = case is_doc_page(post.0) {
True -> doc.page(post.1, doc_pages)
False -> doc.page(post.1, doc_pages)
@ -124,81 +147,152 @@ fn is_doc_page(slug: String) {
}
fn nav() -> element.Element(a) {
html.nav([attribute.class("flex sticky top-0 w-full z-50 border-b border-b-zinc-300 backdrop-blur-md h-12")], [
html.nav(
[
attribute.class(
"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.div([attribute.class("flex my-auto px-2")], [
html.div([], [
html.a([attribute.href("/"), attribute.class("flex items-center gap-1")], [
html.a(
[attribute.href("/"), attribute.class("flex items-center gap-1")],
[
html.img([
attribute.src("/hilbish-flower.png"),
attribute.class("h-6")
attribute.class("h-16"),
]),
html.span([
attribute.class("self-center text-2xl")
], [
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) {
html.footer([attribute.class("py-4 px-6 flex flex-row justify-around border-t border-t-zinc-300")], [
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")], [
html.a([attribute.href(conf.base_url), attribute.class("flex items-center gap-1")], [
html.a(
[
attribute.href(conf.base_url),
attribute.class("flex items-center gap-1"),
],
[
html.img([
attribute.src("/hilbish-flower.png"),
attribute.class("h-24")
attribute.class("h-24"),
]),
html.span([
attribute.class("self-center text-6xl")
], [
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.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")
])
])
link("https://github.com/Rosettea/Hilbish", "GitHub"),
]),
],
)
}
fn create_page(content: element.Element(a)) -> element.Element(a) {
let description = "Something Unique. Hilbish is the new interactive shell for Lua fans. Extensible, scriptable, configurable: All in Lua."
html.html([attribute.class("bg-stone-50 dark:bg-neutral-900 text-black dark:text-white")], [
fn create_page(content: element.Element(a)) -> element.Element(a) {
let description =
"Something Unique. Hilbish is the new interactive shell for Lua fans. Extensible, scriptable, configurable: All in Lua."
html.html(
[
attribute.class(
"bg-stone-50 dark:bg-neutral-900 text-black dark:text-white",
),
],
[
html.head([], [
html.meta([
attribute.name("viewport"),
attribute.attribute("content", "width=device-width, initial-scale=1.0")
attribute.attribute(
"content",
"width=device-width, initial-scale=1.0",
),
]),
html.link([
attribute.rel("stylesheet"),
attribute.href(conf.base_url_join("tailwind.css"))
attribute.href(conf.base_url_join("tailwind.css")),
]),
html.title([], "Hilbish"),
html.meta([attribute.name("theme-color"), attribute.content("#ff89dd")]),
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.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.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.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) {
html.a([attribute.href(url)], [
html.span([attribute.class("text-pink-300 text-light")], [element.text(text)])
html.span([attribute.class("text-pink-300 text-light")], [
element.text(text),
]),
])
}