2
2
mirror of https://github.com/Hilbis/Hilbish synced 2025-07-01 08:42:04 +00:00

fix: doc descriptions, add short description, make things scroll nicer

This commit is contained in:
sammyette 2025-06-22 18:51:57 -04:00
parent da5a1d0e34
commit 4b28efe639
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD
19 changed files with 555 additions and 299 deletions

View File

@ -403,7 +403,7 @@ func main() {
shortDesc := piece.Doc[0]
desc := piece.Doc[1:]
interfaceModules[modname].ShortDescription = shortDesc
interfaceModules[modname].Description = strings.Join(desc, "\n")
interfaceModules[modname].Description = strings.Replace(strings.Join(desc, "\n"), "<nl>", "\\\n \\", -1)
interfaceModules[modname].Fields = piece.Fields
interfaceModules[modname].Properties = piece.Properties
continue
@ -441,7 +441,7 @@ func main() {
Types: filteredTypePieces,
Docs: filteredPieces,
ShortDescription: shortDesc,
Description: strings.Join(desc, "\n"),
Description: strings.Replace(strings.Join(desc, "\n"), "<nl>", "\\\n \\", -1),
HasInterfaces: hasInterfaces,
Properties: docPieceTag("property", tags),
Fields: docPieceTag("field", tags),
@ -627,6 +627,7 @@ func generateFile(v module) {
<i class="fas fa-paperclip"></i>
</a>
</h4>
</div>
`, htmlSig, dps.FuncName))
f.WriteString("```\n\n")

View File

@ -1,7 +1,7 @@
{
"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.",
"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 \\\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 \\\n\nExamples of this are in the Hilbish default config!\nConsider this part of it:\\\n \\\n\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": [

View File

@ -1,7 +1,7 @@
{
"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.",
"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\n- `in` is the standard input. You may use the read functions on this sink to get input from the user.\n- `out` is standard output. This is usually where command output should go.\n- `err` is standard error. This sink is for writing errors, as the name would suggest.",
"properties": [],
"fields": [],
"docs": [

View File

@ -1,9 +1,147 @@
{
"name": "hilbish",
"shortDescription": "",
"description": "",
"shortDescription": "the core Hilbish API",
"description": "The Hilbish module includes the core API, containing\ninterfaces and functions which directly relate to shell functionality.",
"properties": [],
"fields": [],
"fields": [
{
"name": "ver",
"description": [
"The",
"version",
"of",
"Hilbish"
],
"isInterface": false,
"isMember": false,
"isType": false
},
{
"name": "goVersion",
"description": [
"The",
"version",
"of",
"Go",
"that",
"Hilbish",
"was",
"compiled",
"with"
],
"isInterface": false,
"isMember": false,
"isType": false
},
{
"name": "user",
"description": [
"Username",
"of",
"the",
"user"
],
"isInterface": false,
"isMember": false,
"isType": false
},
{
"name": "host",
"description": [
"Hostname",
"of",
"the",
"machine"
],
"isInterface": false,
"isMember": false,
"isType": false
},
{
"name": "dataDir",
"description": [
"Directory",
"for",
"Hilbish",
"data",
"files,",
"including",
"the",
"docs",
"and",
"default",
"modules"
],
"isInterface": false,
"isMember": false,
"isType": false
},
{
"name": "interactive",
"description": [
"Is",
"Hilbish",
"in",
"an",
"interactive",
"shell?"
],
"isInterface": false,
"isMember": false,
"isType": false
},
{
"name": "login",
"description": [
"Is",
"Hilbish",
"the",
"login",
"shell?"
],
"isInterface": false,
"isMember": false,
"isType": false
},
{
"name": "vimMode",
"description": [
"Current",
"Vim",
"input",
"mode",
"of",
"Hilbish",
"(will",
"be",
"nil",
"if",
"not",
"in",
"Vim",
"input",
"mode)"
],
"isInterface": false,
"isMember": false,
"isType": false
},
{
"name": "exitCode",
"description": [
"Exit",
"code",
"of",
"the",
"last",
"executed",
"command"
],
"isInterface": false,
"isMember": false,
"isType": false
}
],
"types": [
{
"name": "Sink",
@ -26,6 +164,127 @@
}
],
"docs": [
{
"name": "luaSinkAutoFlush",
"description": [
"Sets/toggles the option of automatically flushing output.",
"A call with no argument will toggle the value."
],
"signature": "autoFlush(auto)",
"goFuncName": "luasinkautoflush",
"isInterface": false,
"isMember": true,
"isType": false,
"tags": {
"member": [
{
"id": "",
"fields": null,
"startIdx": 0
}
]
}
},
{
"name": "luaSinkFlush",
"description": [
"Flush writes all buffered input to the sink."
],
"signature": "flush()",
"goFuncName": "luasinkflush",
"isInterface": false,
"isMember": true,
"isType": false,
"tags": {
"member": [
{
"id": "",
"fields": null,
"startIdx": 0
}
]
}
},
{
"name": "luaSinkRead",
"description": [
"Reads a liine of input from the sink."
],
"signature": "read() -\u003e string",
"goFuncName": "luasinkread",
"isInterface": false,
"isMember": true,
"isType": false,
"tags": {
"member": [
{
"id": "",
"fields": null,
"startIdx": 0
}
]
}
},
{
"name": "luaSinkReadAll",
"description": [
"Reads all input from the sink."
],
"signature": "readAll() -\u003e string",
"goFuncName": "luasinkreadall",
"isInterface": false,
"isMember": true,
"isType": false,
"tags": {
"member": [
{
"id": "",
"fields": null,
"startIdx": 0
}
]
}
},
{
"name": "luaSinkWrite",
"description": [
"Writes data to a sink."
],
"signature": "write(str)",
"goFuncName": "luasinkwrite",
"isInterface": false,
"isMember": true,
"isType": false,
"tags": {
"member": [
{
"id": "",
"fields": null,
"startIdx": 0
}
]
}
},
{
"name": "luaSinkWriteln",
"description": [
"Writes data to a sink with a newline at the end."
],
"signature": "writeln(str)",
"goFuncName": "luasinkwriteln",
"isInterface": false,
"isMember": true,
"isType": false,
"tags": {
"member": [
{
"id": "",
"fields": null,
"startIdx": 0
}
]
}
},
{
"name": "alias",
"description": [
@ -869,127 +1128,6 @@
}
]
}
},
{
"name": "luaSinkAutoFlush",
"description": [
"Sets/toggles the option of automatically flushing output.",
"A call with no argument will toggle the value."
],
"signature": "autoFlush(auto)",
"goFuncName": "luasinkautoflush",
"isInterface": false,
"isMember": true,
"isType": false,
"tags": {
"member": [
{
"id": "",
"fields": null,
"startIdx": 0
}
]
}
},
{
"name": "luaSinkFlush",
"description": [
"Flush writes all buffered input to the sink."
],
"signature": "flush()",
"goFuncName": "luasinkflush",
"isInterface": false,
"isMember": true,
"isType": false,
"tags": {
"member": [
{
"id": "",
"fields": null,
"startIdx": 0
}
]
}
},
{
"name": "luaSinkRead",
"description": [
"Reads a liine of input from the sink."
],
"signature": "read() -\u003e string",
"goFuncName": "luasinkread",
"isInterface": false,
"isMember": true,
"isType": false,
"tags": {
"member": [
{
"id": "",
"fields": null,
"startIdx": 0
}
]
}
},
{
"name": "luaSinkReadAll",
"description": [
"Reads all input from the sink."
],
"signature": "readAll() -\u003e string",
"goFuncName": "luasinkreadall",
"isInterface": false,
"isMember": true,
"isType": false,
"tags": {
"member": [
{
"id": "",
"fields": null,
"startIdx": 0
}
]
}
},
{
"name": "luaSinkWrite",
"description": [
"Writes data to a sink."
],
"signature": "write(str)",
"goFuncName": "luasinkwrite",
"isInterface": false,
"isMember": true,
"isType": false,
"tags": {
"member": [
{
"id": "",
"fields": null,
"startIdx": 0
}
]
}
},
{
"name": "luaSinkWriteln",
"description": [
"Writes data to a sink with a newline at the end."
],
"signature": "writeln(str)",
"goFuncName": "luasinkwriteln",
"isInterface": false,
"isMember": true,
"isType": false,
"tags": {
"member": [
{
"id": "",
"fields": null,
"startIdx": 0
}
]
}
}
],
"interfaces": {

View File

@ -13,15 +13,19 @@ menu:
Bait is the event emitter for Hilbish. Much like Node.js and
its `events` system, many actions in Hilbish emit events.
Unlike Node.js, Hilbish events are global. So make sure to
pick a unique name!
pick a unique name!\
\
Usage of the Bait module consists of userstanding
event-driven architecture, but it's pretty simple:
If you want to act on a certain event, you can `catch` it.
You can act on events via callback functions.
You can act on events via callback functions.\
\
Examples of this are in the Hilbish default config!
Consider this part of it:
Consider this part of it:\
\
```lua
bait.catch('command.exit', function(code)
running = false
@ -75,6 +79,7 @@ bait.catch(name, cb)
<i class="fas fa-paperclip"></i>
</a>
</h4>
</div>
```
@ -106,6 +111,7 @@ bait.catchOnce(name, cb)
<i class="fas fa-paperclip"></i>
</a>
</h4>
</div>
```
@ -130,6 +136,7 @@ bait.hooks(name) -> table
<i class="fas fa-paperclip"></i>
</a>
</h4>
</div>
```
@ -151,6 +158,7 @@ bait.release(name, catcher)
<i class="fas fa-paperclip"></i>
</a>
</h4>
</div>
```
@ -188,6 +196,7 @@ bait.throw(name, ...args)
<i class="fas fa-paperclip"></i>
</a>
</h4>
</div>
```

View File

@ -13,8 +13,8 @@ menu:
Commander is the library which handles Hilbish commands. This makes
the user able to add Lua-written commands to their shell without making
a separate script in a bin folder. Instead, you may simply use the Commander
library in your Hilbish config.
library in your Hilbish config.\
\
```lua
local commander = require 'commander'
@ -25,20 +25,18 @@ end)
In this example, a command with the name of `hello` is created
that will print `Hello world!` to output. One question you may
have is: What is the `sinks` parameter?
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 @Sink.
In the future, `sinks.in` will be removed.
In the future, `sinks.in` will be removed.\
\
- `in` is the standard input.
You may use the read functions on this sink to get input from the user.
- `out` is standard output.
This is usually where command output should go.
- `err` is standard error.
This sink is for writing errors, as the name would suggest.
- `in` is the standard input. You may use the read functions on this sink to get input from the user.
- `out` is standard output. This is usually where command output should go.
- `err` is standard error. This sink is for writing errors, as the name would suggest.
## Functions
@ -74,6 +72,7 @@ commander.deregister(name)
<i class="fas fa-paperclip"></i>
</a>
</h4>
</div>
```
@ -95,6 +94,7 @@ commander.register(name, cb)
<i class="fas fa-paperclip"></i>
</a>
</h4>
</div>
```
@ -132,6 +132,7 @@ commander.registry() -> table
<i class="fas fa-paperclip"></i>
</a>
</h4>
</div>
```

View File

@ -91,6 +91,7 @@ fs.abs(path) -> string
<i class="fas fa-paperclip"></i>
</a>
</h4>
</div>
```
@ -113,6 +114,7 @@ fs.basename(path) -> string
<i class="fas fa-paperclip"></i>
</a>
</h4>
</div>
```
@ -135,6 +137,7 @@ fs.cd(dir)
<i class="fas fa-paperclip"></i>
</a>
</h4>
</div>
```
@ -156,6 +159,7 @@ fs.dir(path) -> string
<i class="fas fa-paperclip"></i>
</a>
</h4>
</div>
```
@ -178,6 +182,7 @@ fs.glob(pattern) -> matches (table)
<i class="fas fa-paperclip"></i>
</a>
</h4>
</div>
```
@ -214,6 +219,7 @@ fs.join(...path) -> string
<i class="fas fa-paperclip"></i>
</a>
</h4>
</div>
```
@ -242,6 +248,7 @@ fs.mkdir(name, recursive)
<i class="fas fa-paperclip"></i>
</a>
</h4>
</div>
```
@ -274,6 +281,7 @@ fs.fpipe() -> File, File
<i class="fas fa-paperclip"></i>
</a>
</h4>
</div>
```
@ -294,6 +302,7 @@ fs.readdir(path) -> table[string]
<i class="fas fa-paperclip"></i>
</a>
</h4>
</div>
```
@ -315,6 +324,7 @@ fs.stat(path) -> {}
<i class="fas fa-paperclip"></i>
</a>
</h4>
</div>
```

View File

@ -1,6 +1,6 @@
---
title: Module hilbish
description:
description: the core Hilbish API
layout: doc
menu:
docs:
@ -9,7 +9,8 @@ menu:
## Introduction
The Hilbish module includes the core API, containing
interfaces and functions which directly relate to shell functionality.
## Functions
@ -86,6 +87,53 @@ menu:
</div>
```
## 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
@ -97,6 +145,7 @@ hilbish.alias(cmd, orig)
<i class="fas fa-paperclip"></i>
</a>
</h4>
</div>
```
@ -131,6 +180,7 @@ hilbish.appendPath(dir)
<i class="fas fa-paperclip"></i>
</a>
</h4>
</div>
```
@ -164,6 +214,7 @@ hilbish.complete(scope, cb)
<i class="fas fa-paperclip"></i>
</a>
</h4>
</div>
```
@ -219,6 +270,7 @@ hilbish.cwd() -> string
<i class="fas fa-paperclip"></i>
</a>
</h4>
</div>
```
@ -238,6 +290,7 @@ hilbish.exec(cmd)
<i class="fas fa-paperclip"></i>
</a>
</h4>
</div>
```
@ -260,6 +313,7 @@ hilbish.goro(fn)
<i class="fas fa-paperclip"></i>
</a>
</h4>
</div>
```
@ -284,6 +338,7 @@ hilbish.highlighter(line)
<i class="fas fa-paperclip"></i>
</a>
</h4>
</div>
```
@ -319,6 +374,7 @@ hilbish.hinter(line, pos)
<i class="fas fa-paperclip"></i>
</a>
</h4>
</div>
```
@ -355,6 +411,7 @@ hilbish.inputMode(mode)
<i class="fas fa-paperclip"></i>
</a>
</h4>
</div>
```
@ -378,6 +435,7 @@ hilbish.interval(cb, time) -> @Timer
<i class="fas fa-paperclip"></i>
</a>
</h4>
</div>
```
@ -403,6 +461,7 @@ hilbish.multiprompt(str)
<i class="fas fa-paperclip"></i>
</a>
</h4>
</div>
```
@ -444,6 +503,7 @@ hilbish.prependPath(dir)
<i class="fas fa-paperclip"></i>
</a>
</h4>
</div>
```
@ -465,6 +525,7 @@ hilbish.prompt(str, typ)
<i class="fas fa-paperclip"></i>
</a>
</h4>
</div>
```
@ -503,6 +564,7 @@ hilbish.read(prompt) -> input (string)
<i class="fas fa-paperclip"></i>
</a>
</h4>
</div>
```
@ -526,6 +588,7 @@ hilbish.timeout(cb, time) -> @Timer
<i class="fas fa-paperclip"></i>
</a>
</h4>
</div>
```
@ -551,6 +614,7 @@ hilbish.which(name) -> string
<i class="fas fa-paperclip"></i>
</a>
</h4>
</div>
```

View File

@ -41,6 +41,7 @@ readline.new() -> @Readline
<i class="fas fa-paperclip"></i>
</a>
</h4>
</div>
```

View File

@ -40,6 +40,7 @@ snail.new() -> @Snail
<i class="fas fa-paperclip"></i>
</a>
</h4>
</div>
```

View File

@ -49,6 +49,7 @@ terminal.restoreState()
<i class="fas fa-paperclip"></i>
</a>
</h4>
</div>
```
@ -68,6 +69,7 @@ terminal.saveState()
<i class="fas fa-paperclip"></i>
</a>
</h4>
</div>
```
@ -87,6 +89,7 @@ terminal.setRaw()
<i class="fas fa-paperclip"></i>
</a>
</h4>
</div>
```
@ -106,6 +109,7 @@ terminal.size()
<i class="fas fa-paperclip"></i>
</a>
</h4>
</div>
```

View File

@ -49,6 +49,7 @@ yarn.thread(fun) -> @Thread
<i class="fas fa-paperclip"></i>
</a>
</h4>
</div>
```

View File

@ -3,15 +3,14 @@
Bait is the event emitter for Hilbish. Much like Node.js and
its `events` system, many actions in Hilbish emit events.
Unlike Node.js, Hilbish events are global. So make sure to
pick a unique name!
pick a unique name!<nl>
Usage of the Bait module consists of userstanding
event-driven architecture, but it's pretty simple:
If you want to act on a certain event, you can `catch` it.
You can act on events via callback functions.
You can act on events via callback functions.<nl>
Examples of this are in the Hilbish default config!
Consider this part of it:
Consider this part of it:<nl>
```lua
bait.catch('command.exit', function(code)
running = false
@ -30,11 +29,12 @@ import (
"hilbish/util"
rt "github.com/arnodel/golua/runtime"
"github.com/arnodel/golua/lib/packagelib"
rt "github.com/arnodel/golua/runtime"
)
type listenerType int
const (
goListener listenerType = iota
luaListener
@ -44,14 +44,14 @@ const (
type Recoverer func(event string, handler *Listener, err interface{})
// Listener is a struct that holds the handler for an event.
type Listener struct{
type Listener struct {
typ listenerType
once bool
caller func(...interface{}) rt.Value
luaCaller *rt.Closure
}
type Bait struct{
type Bait struct {
Loader packagelib.Loader
recoverer Recoverer
handlers map[string][]*Listener
@ -93,8 +93,10 @@ func (b *Bait) Emit(event string, args ...interface{}) []rt.Value {
for _, arg := range args {
var luarg rt.Value
switch arg.(type) {
case rt.Value: luarg = arg.(rt.Value)
default: luarg = rt.AsValue(arg)
case rt.Value:
luarg = arg.(rt.Value)
default:
luarg = rt.AsValue(arg)
}
luaArgs = append(luaArgs, luarg)
}
@ -208,11 +210,10 @@ func (b *Bait) addListener(event string, listener *Listener) {
b.handlers[event] = append(b.handlers[event], listener)
}
func (b *Bait) removeListener(event string, idx int) {
b.handlers[event][idx] = b.handlers[event][len(b.handlers[event]) - 1]
b.handlers[event][idx] = b.handlers[event][len(b.handlers[event])-1]
b.handlers[event] = b.handlers[event][:len(b.handlers[event]) - 1]
b.handlers[event] = b.handlers[event][:len(b.handlers[event])-1]
}
func (b *Bait) callRecoverer(event string, handler *Listener, err interface{}) {
@ -294,8 +295,10 @@ func (b *Bait) bhooks(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
luaHandlers := rt.NewTable()
for _, handler := range handlers {
if handler.typ != luaListener { continue }
luaHandlers.Set(rt.IntValue(luaHandlers.Len() + 1), rt.FunctionValue(handler.luaCaller))
if handler.typ != luaListener {
continue
}
luaHandlers.Set(rt.IntValue(luaHandlers.Len()+1), rt.FunctionValue(handler.luaCaller))
}
if luaHandlers.Len() == 0 {

View File

@ -3,8 +3,7 @@
Commander is the library which handles Hilbish commands. This makes
the user able to add Lua-written commands to their shell without making
a separate script in a bin folder. Instead, you may simply use the Commander
library in your Hilbish config.
library in your Hilbish config.<nl>
```lua
local commander = require 'commander'
@ -15,32 +14,27 @@ end)
In this example, a command with the name of `hello` is created
that will print `Hello world!` to output. One question you may
have is: What is the `sinks` parameter?
have is: What is the `sinks` parameter?<nl>
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 @Sink.
In the future, `sinks.in` will be removed.
- `in` is the standard input.
You may use the read functions on this sink to get input from the user.
- `out` is standard output.
This is usually where command output should go.
- `err` is standard error.
This sink is for writing errors, as the name would suggest.
In the future, `sinks.in` will be removed.<nl>
- `in` is the standard input. You may use the read functions on this sink to get input from the user.
- `out` is standard output. This is usually where command output should go.
- `err` is standard error. This sink is for writing errors, as the name would suggest.
*/
package commander
import (
"hilbish/util"
"hilbish/golibs/bait"
"hilbish/util"
rt "github.com/arnodel/golua/runtime"
"github.com/arnodel/golua/lib/packagelib"
rt "github.com/arnodel/golua/runtime"
)
type Commander struct{
type Commander struct {
Events *bait.Bait
Loader packagelib.Loader
Commands map[string]*rt.Closure

View File

@ -4,23 +4,17 @@ description: Steps on how to install Hilbish on all the OSes and distros support
layout: page
---
There are a small amount of ways to grab Hilbish. You can download the releases from GitHub, use your package manager, or build from source.
## Official Binaries
The best way to get Hilbish is to get a build directly from GitHub.
The easiest way to get Hilbish is to get a build directly from GitHub.
At any time, there are 2 versions of Hilbish available to install:
the latest stable release, and development builds from the master branch.
the latest stable release, and development builds from the master branch.\
You can download both at any time, but note that the development builds may have breaking changes.\
To download the latest stable release, [see here](https://github.com/Rosettea/Hilbish/releases/latest)
You can download both at any time, but note that the development builds may
have breaking changes.
For the latest *stable release*, check here: https://github.com/Rosettea/Hilbish/releases/latest
For a *development build*: https://nightly.link/Rosettea/Hilbish/workflows/build/master
## Compiling
To read the steps for compiling Hilbish, head over to the [GitHub repository.](https://github.com/Rosettea/Hilbish#build)
For the latest development build, [click here](https://nightly.link/Rosettea/Hilbish/workflows/build/master)
## Package Repositories
@ -47,3 +41,7 @@ Or, from master branch: `yay -S hilbish-git`
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`
## Compiling From Source
To see steps on compiling Hilbish from source, [visit the GitHub repository](https://github.com/Rosettea/Hilbish#build)

View File

@ -21,7 +21,7 @@ pub fn page(
this_slug: String,
doc_pages_list,
) -> element.Element(a) {
html.div([attribute.class("flex-auto flex flex-col overflow-none")], [
html.div([attribute.class("flex-1 flex flex-col overflow-hidden")], [
html.div(
[
attribute.class(
@ -43,7 +43,7 @@ pub fn page(
html.span([attribute.class("font-bold")], [element.text(p.title)]),
],
),
html.div([attribute.class("h-full sm:flex grid")], [
html.div([attribute.class("flex-1 sm:flex grid overflow-hidden")], [
html.input([
attribute.type_("checkbox"),
attribute.id("sidebar-toggle"),
@ -52,7 +52,7 @@ pub fn page(
html.div(
[
attribute.class(
"p-4 sm:border-r sm:border-r-zinc-300 col-start-1 row-start-1 bg-neutral-100 dark:bg-neutral-950 basis-2/10 transition-transform duration-300 -translate-x-full peer-checked:translate-x-0 sm:translate-x-0 z-30",
"overflow-y-scroll p-4 sm:border-r sm:border-r-zinc-300 col-start-1 row-start-1 bg-neutral-100 dark:bg-neutral-950 basis-2/10 transition-transform duration-300 -translate-x-full peer-checked:translate-x-0 sm:translate-x-0 z-30",
),
],
[
@ -187,18 +187,24 @@ pub fn page(
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",
"flex-1 flex justify-center 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",
),
],
[
html.h1([attribute.class("my-3 font-bold text-4xl")], [
element.text(p.title),
]),
html.div([attribute.class("flex-1 flex flex-col overflow-y-auto")], [
// 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))
html.div([attribute.class("flex-1 w-3/4 self-center p-8")], [
html.h1([attribute.class("my-3 font-bold text-4xl")], [
element.text(p.title),
]),
html.i([], [element.text(p.description)]),
..render_doc(p.contents)
]),
util.footer(),
]),
],
),
]),
@ -218,7 +224,8 @@ fn render_doc(md: String) {
}
let margin = case level {
1 -> "my-2"
1 -> "my-4"
2 -> "my-2"
_ -> "my-1"
}

View File

@ -4,6 +4,7 @@ import gleam/option
pub type Post {
Post(
name: String,
description: String,
title: String,
slug: String,
metadata: option.Option(glaml.Document),

View File

@ -6,6 +6,7 @@ import lustre/attribute
import lustre/element
import lustre/element/html
import conf
import glaml
import post
@ -68,3 +69,74 @@ pub fn link(url: String, text: String, out: Bool) {
],
)
}
pub fn nav() -> element.Element(a) {
html.nav(
[
attribute.class(
"bg-stone-100/80 dark:bg-neutral-950/80 flex justify-around sticky items-center top-0 w-full z-50 border-b border-b-zinc-300 backdrop-blur-md h-12",
),
],
[
html.div([attribute.class("flex my-auto px-2")], [
html.div([], [
html.a(
[attribute.href("/"), attribute.class("flex items-center gap-1")],
[
html.img([
attribute.src(conf.base_url_join("/hilbish-flower.png")),
attribute.class("h-8"),
]),
html.span([attribute.class("self-center text-3xl font-medium")], [
element.text("Hilbish"),
]),
],
),
]),
]),
html.div([attribute.class("flex gap-3")], [
link(conf.base_url_join("/install"), "Install", False),
link(conf.base_url_join("/docs"), "Docs", False),
link(conf.base_url_join("/blog"), "Blog", False),
]),
],
)
}
pub 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.div([attribute.class("flex flex-col")], [
html.a(
[
attribute.href(conf.base_url),
attribute.class("flex items-center gap-1"),
],
[
html.img([
attribute.src(conf.base_url_join("/hilbish-flower.png")),
attribute.class("h-24"),
]),
html.span([attribute.class("self-center text-6xl")], [
element.text("Hilbish"),
]),
],
),
html.span([attribute.class("text-xl")], [
element.text("The Moon-powered shell!"),
]),
html.span([attribute.class("text-light text-neutral-500")], [
element.text("MIT License, copyright sammyette 2025"),
]),
]),
html.div([attribute.class("flex flex-col")], [
link("https://github.com/Rosettea/Hilbish", "GitHub", True),
]),
],
)
}

View File

@ -56,8 +56,20 @@ pub fn main() {
option.None -> ""
}
let description = case metadata {
option.Some(metadata) -> {
case
glaml.select_sugar(glaml.document_root(metadata), "description")
{
Ok(glaml.NodeStr(s)) -> s
_ -> ""
}
}
option.None -> ""
}
let assert Ok(filename) = path |> string.split("/") |> list.last
#(slug, post.Post(name, title, slug, metadata, content))
#(slug, post.Post(name, description, title, slug, metadata, content))
})
let doc_pages =
@ -78,14 +90,18 @@ pub fn main() {
let build =
ssg.new("./public")
|> ssg.add_static_dir("static")
|> ssg.add_static_route("/", create_page(index.page()))
|> ssg.add_static_route("/", create_page(index.page(), False))
|> list.fold(posts, _, fn(config, post) {
let page = case is_doc_page(post.0) {
True -> doc.page(post.1, post.0, doc_pages)
False -> doc.page(post.1, post.0, doc_pages)
}
//io.debug(post.0)
ssg.add_static_route(config, post.0, create_page(page))
ssg.add_static_route(
config,
post.0,
create_page(page, is_doc_page(post.0)),
)
})
|> ssg.use_index_routes
|> ssg.build
@ -106,78 +122,10 @@ fn is_doc_page(slug: String) {
}
}
fn nav() -> element.Element(a) {
html.nav(
[
attribute.class(
"bg-stone-100/80 dark:bg-neutral-950/80 flex justify-around sticky items-center top-0 w-full z-50 border-b border-b-zinc-300 backdrop-blur-md h-12",
),
],
[
html.div([attribute.class("flex my-auto px-2")], [
html.div([], [
html.a(
[attribute.href("/"), attribute.class("flex items-center gap-1")],
[
html.img([
attribute.src(conf.base_url_join("/hilbish-flower.png")),
attribute.class("h-8"),
]),
html.span([attribute.class("self-center text-3xl font-medium")], [
element.text("Hilbish"),
]),
],
),
]),
]),
html.div([attribute.class("flex gap-3")], [
util.link(conf.base_url_join("/install"), "Install", False),
util.link(conf.base_url_join("/docs"), "Docs", False),
util.link(conf.base_url_join("/blog"), "Blog", False),
]),
],
)
}
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.div([attribute.class("flex flex-col")], [
html.a(
[
attribute.href(conf.base_url),
attribute.class("flex items-center gap-1"),
],
[
html.img([
attribute.src(conf.base_url_join("/hilbish-flower.png")),
attribute.class("h-24"),
]),
html.span([attribute.class("self-center text-6xl")], [
element.text("Hilbish"),
]),
],
),
html.span([attribute.class("text-xl")], [
element.text("The Moon-powered shell!"),
]),
html.span([attribute.class("text-light text-neutral-500")], [
element.text("MIT License, copyright sammyette 2025"),
]),
]),
html.div([attribute.class("flex flex-col")], [
util.link("https://github.com/Rosettea/Hilbish", "GitHub", True),
]),
],
)
}
fn create_page(content: element.Element(a)) -> element.Element(a) {
fn create_page(
content: element.Element(a),
doc_page: Bool,
) -> element.Element(a) {
let description =
"Something Unique. Hilbish is the new interactive shell for Lua fans. Extensible, scriptable, configurable: All in Lua."
@ -236,10 +184,13 @@ fn create_page(content: element.Element(a)) -> element.Element(a) {
attribute.attribute("property", "og:url"),
]),
]),
html.body([attribute.class("min-h-screen flex flex-col")], [
nav(),
html.body([attribute.class("h-screen flex flex-col")], [
util.nav(),
content,
footer(),
case doc_page {
True -> element.none()
False -> util.footer()
},
]),
],
)