mirror of
https://github.com/Hilbis/Hilbish
synced 2025-07-01 08:42:04 +00:00
Compare commits
8 Commits
da5a1d0e34
...
fa92729288
Author | SHA1 | Date | |
---|---|---|---|
fa92729288 | |||
de238ecfea | |||
793a043c7b | |||
6a41388699 | |||
2a2bf03fad | |||
279ea433e2 | |||
1cbfc35c70 | |||
4b28efe639 |
@ -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")
|
||||
@ -723,7 +724,7 @@ func table(elems [][]string) string {
|
||||
for _, line := range elems {
|
||||
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 class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>")
|
||||
b.WriteString("<td class='p-3 font-medium text-black dark:text-white'>")
|
||||
b.WriteString(col)
|
||||
b.WriteString("</td>\n")
|
||||
}
|
||||
|
@ -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 \\\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\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": [
|
||||
|
@ -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- `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": [
|
||||
|
@ -13,15 +13,16 @@ 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:
|
||||
|
||||
```lua
|
||||
bait.catch('command.exit', function(code)
|
||||
running = false
|
||||
@ -40,24 +41,24 @@ this function will set the user prompt.
|
||||
<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>
|
||||
<td class='p-3 font-medium text-black dark:text-white'><a href="#catch">catch(name, cb)</a></td>
|
||||
<td class='p-3 font-medium text-black 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>
|
||||
<td class='p-3 font-medium text-black dark:text-white'><a href="#catchOnce">catchOnce(name, cb)</a></td>
|
||||
<td class='p-3 font-medium text-black 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>
|
||||
<td class='p-3 font-medium text-black dark:text-white'><a href="#hooks">hooks(name) -> table</a></td>
|
||||
<td class='p-3 font-medium text-black 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>
|
||||
<td class='p-3 font-medium text-black dark:text-white'><a href="#release">release(name, catcher)</a></td>
|
||||
<td class='p-3 font-medium text-black 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>
|
||||
<td class='p-3 font-medium text-black dark:text-white'><a href="#throw">throw(name, ...args)</a></td>
|
||||
<td class='p-3 font-medium text-black dark:text-white'>Throws a hook with `name` with the provided `args`.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@ -75,6 +76,7 @@ bait.catch(name, cb)
|
||||
<i class="fas fa-paperclip"></i>
|
||||
</a>
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
```
|
||||
|
||||
@ -106,6 +108,7 @@ bait.catchOnce(name, cb)
|
||||
<i class="fas fa-paperclip"></i>
|
||||
</a>
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
```
|
||||
|
||||
@ -130,6 +133,7 @@ bait.hooks(name) -> table
|
||||
<i class="fas fa-paperclip"></i>
|
||||
</a>
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
```
|
||||
|
||||
@ -151,6 +155,7 @@ bait.release(name, catcher)
|
||||
<i class="fas fa-paperclip"></i>
|
||||
</a>
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
```
|
||||
|
||||
@ -188,6 +193,7 @@ bait.throw(name, ...args)
|
||||
<i class="fas fa-paperclip"></i>
|
||||
</a>
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
```
|
||||
|
||||
|
@ -25,20 +25,17 @@ 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` 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.\
|
||||
\
|
||||
- `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
|
||||
|
||||
@ -47,16 +44,16 @@ This sink is for writing errors, as the name would suggest.
|
||||
<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>
|
||||
<td class='p-3 font-medium text-black dark:text-white'><a href="#deregister">deregister(name)</a></td>
|
||||
<td class='p-3 font-medium text-black 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>
|
||||
<td class='p-3 font-medium text-black dark:text-white'><a href="#register">register(name, cb)</a></td>
|
||||
<td class='p-3 font-medium text-black 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>
|
||||
<td class='p-3 font-medium text-black dark:text-white'><a href="#registry">registry() -> table</a></td>
|
||||
<td class='p-3 font-medium text-black dark:text-white'>Returns all registered commanders. Returns a list of tables with the following keys:</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@ -74,6 +71,7 @@ commander.deregister(name)
|
||||
<i class="fas fa-paperclip"></i>
|
||||
</a>
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
```
|
||||
|
||||
@ -95,6 +93,7 @@ commander.register(name, cb)
|
||||
<i class="fas fa-paperclip"></i>
|
||||
</a>
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
```
|
||||
|
||||
@ -132,6 +131,7 @@ commander.registry() -> table
|
||||
<i class="fas fa-paperclip"></i>
|
||||
</a>
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
```
|
||||
|
||||
|
@ -21,44 +21,44 @@ library offers more functions and will work on any operating system Hilbish does
|
||||
<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>
|
||||
<td class='p-3 font-medium text-black dark:text-white'><a href="#abs">abs(path) -> string</a></td>
|
||||
<td class='p-3 font-medium text-black 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>
|
||||
<td class='p-3 font-medium text-black dark:text-white'><a href="#basename">basename(path) -> string</a></td>
|
||||
<td class='p-3 font-medium text-black 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>
|
||||
<td class='p-3 font-medium text-black dark:text-white'><a href="#cd">cd(dir)</a></td>
|
||||
<td class='p-3 font-medium text-black 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>
|
||||
<td class='p-3 font-medium text-black dark:text-white'><a href="#dir">dir(path) -> string</a></td>
|
||||
<td class='p-3 font-medium text-black 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>
|
||||
<td class='p-3 font-medium text-black dark:text-white'><a href="#glob">glob(pattern) -> matches (table)</a></td>
|
||||
<td class='p-3 font-medium text-black 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>
|
||||
<td class='p-3 font-medium text-black dark:text-white'><a href="#join">join(...path) -> string</a></td>
|
||||
<td class='p-3 font-medium text-black 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>
|
||||
<td class='p-3 font-medium text-black dark:text-white'><a href="#mkdir">mkdir(name, recursive)</a></td>
|
||||
<td class='p-3 font-medium text-black 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>
|
||||
<td class='p-3 font-medium text-black dark:text-white'><a href="#pipe">fpipe() -> File, File</a></td>
|
||||
<td class='p-3 font-medium text-black 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>
|
||||
<td class='p-3 font-medium text-black dark:text-white'><a href="#readdir">readdir(path) -> table[string]</a></td>
|
||||
<td class='p-3 font-medium text-black 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>
|
||||
<td class='p-3 font-medium text-black dark:text-white'><a href="#stat">stat(path) -> {}</a></td>
|
||||
<td class='p-3 font-medium text-black dark:text-white'>Returns the information about a given `path`.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@ -72,8 +72,8 @@ library offers more functions and will work on any operating system Hilbish does
|
||||
<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>
|
||||
<td class='p-3 font-medium text-black dark:text-white'>pathSep</td>
|
||||
<td class='p-3 font-medium text-black dark:text-white'>The operating system's path separator.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@ -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>
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,68 +18,68 @@ menu:
|
||||
<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="#alias">alias(cmd, orig)</a></td>
|
||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Sets an alias, with a name of `cmd` to another command.</td>
|
||||
<td class='p-3 font-medium text-black dark:text-white'><a href="#alias">alias(cmd, orig)</a></td>
|
||||
<td class='p-3 font-medium text-black dark:text-white'>Sets an alias, with a name of `cmd` to another command.</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="#appendPath">appendPath(dir)</a></td>
|
||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Appends the provided dir to the command path (`$PATH`)</td>
|
||||
<td class='p-3 font-medium text-black dark:text-white'><a href="#appendPath">appendPath(dir)</a></td>
|
||||
<td class='p-3 font-medium text-black dark:text-white'>Appends the provided dir to the command path (`$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="#complete">complete(scope, cb)</a></td>
|
||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Registers a completion handler for the specified scope.</td>
|
||||
<td class='p-3 font-medium text-black dark:text-white'><a href="#complete">complete(scope, cb)</a></td>
|
||||
<td class='p-3 font-medium text-black dark:text-white'>Registers a completion handler for the specified scope.</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="#cwd">cwd() -> string</a></td>
|
||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Returns the current directory of the shell.</td>
|
||||
<td class='p-3 font-medium text-black dark:text-white'><a href="#cwd">cwd() -> string</a></td>
|
||||
<td class='p-3 font-medium text-black dark:text-white'>Returns the current directory of the 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'><a href="#exec">exec(cmd)</a></td>
|
||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Replaces the currently running Hilbish instance with the supplied command.</td>
|
||||
<td class='p-3 font-medium text-black dark:text-white'><a href="#exec">exec(cmd)</a></td>
|
||||
<td class='p-3 font-medium text-black dark:text-white'>Replaces the currently running Hilbish instance with the supplied command.</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="#goro">goro(fn)</a></td>
|
||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Puts `fn` in a Goroutine.</td>
|
||||
<td class='p-3 font-medium text-black dark:text-white'><a href="#goro">goro(fn)</a></td>
|
||||
<td class='p-3 font-medium text-black dark:text-white'>Puts `fn` in a Goroutine.</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="#highlighter">highlighter(line)</a></td>
|
||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Line highlighter handler.</td>
|
||||
<td class='p-3 font-medium text-black dark:text-white'><a href="#highlighter">highlighter(line)</a></td>
|
||||
<td class='p-3 font-medium text-black dark:text-white'>Line highlighter handler.</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="#hinter">hinter(line, pos)</a></td>
|
||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>The command line hint handler. It gets called on every key insert to</td>
|
||||
<td class='p-3 font-medium text-black dark:text-white'><a href="#hinter">hinter(line, pos)</a></td>
|
||||
<td class='p-3 font-medium text-black dark:text-white'>The command line hint handler. It gets called on every key insert to</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="#inputMode">inputMode(mode)</a></td>
|
||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Sets the input mode for Hilbish's line reader.</td>
|
||||
<td class='p-3 font-medium text-black dark:text-white'><a href="#inputMode">inputMode(mode)</a></td>
|
||||
<td class='p-3 font-medium text-black dark:text-white'>Sets the input mode for Hilbish's line reader.</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="#interval">interval(cb, time) -> @Timer</a></td>
|
||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Runs the `cb` function every specified amount of `time`.</td>
|
||||
<td class='p-3 font-medium text-black dark:text-white'><a href="#interval">interval(cb, time) -> @Timer</a></td>
|
||||
<td class='p-3 font-medium text-black dark:text-white'>Runs the `cb` function every specified amount of `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="#multiprompt">multiprompt(str)</a></td>
|
||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Changes the text prompt when Hilbish asks for more input.</td>
|
||||
<td class='p-3 font-medium text-black dark:text-white'><a href="#multiprompt">multiprompt(str)</a></td>
|
||||
<td class='p-3 font-medium text-black dark:text-white'>Changes the text prompt when Hilbish asks for more input.</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="#prependPath">prependPath(dir)</a></td>
|
||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Prepends `dir` to $PATH.</td>
|
||||
<td class='p-3 font-medium text-black dark:text-white'><a href="#prependPath">prependPath(dir)</a></td>
|
||||
<td class='p-3 font-medium text-black dark:text-white'>Prepends `dir` to $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="#prompt">prompt(str, typ)</a></td>
|
||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Changes the shell prompt to the provided string.</td>
|
||||
<td class='p-3 font-medium text-black dark:text-white'><a href="#prompt">prompt(str, typ)</a></td>
|
||||
<td class='p-3 font-medium text-black dark:text-white'>Changes the shell prompt to the provided string.</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="#read">read(prompt) -> input (string)</a></td>
|
||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Read input from the user, using Hilbish's line editor/input reader.</td>
|
||||
<td class='p-3 font-medium text-black dark:text-white'><a href="#read">read(prompt) -> input (string)</a></td>
|
||||
<td class='p-3 font-medium text-black dark:text-white'>Read input from the user, using Hilbish's line editor/input reader.</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="#timeout">timeout(cb, time) -> @Timer</a></td>
|
||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Executed the `cb` function after a period of `time`.</td>
|
||||
<td class='p-3 font-medium text-black dark:text-white'><a href="#timeout">timeout(cb, time) -> @Timer</a></td>
|
||||
<td class='p-3 font-medium text-black dark:text-white'>Executed the `cb` function after a period of `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="#which">which(name) -> string</a></td>
|
||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Checks if `name` is a valid command.</td>
|
||||
<td class='p-3 font-medium text-black dark:text-white'><a href="#which">which(name) -> string</a></td>
|
||||
<td class='p-3 font-medium text-black dark:text-white'>Checks if `name` is a valid command.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@ -97,6 +97,7 @@ hilbish.alias(cmd, orig)
|
||||
<i class="fas fa-paperclip"></i>
|
||||
</a>
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
```
|
||||
|
||||
@ -131,6 +132,7 @@ hilbish.appendPath(dir)
|
||||
<i class="fas fa-paperclip"></i>
|
||||
</a>
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
```
|
||||
|
||||
@ -164,6 +166,7 @@ hilbish.complete(scope, cb)
|
||||
<i class="fas fa-paperclip"></i>
|
||||
</a>
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
```
|
||||
|
||||
@ -219,6 +222,7 @@ hilbish.cwd() -> string
|
||||
<i class="fas fa-paperclip"></i>
|
||||
</a>
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
```
|
||||
|
||||
@ -238,6 +242,7 @@ hilbish.exec(cmd)
|
||||
<i class="fas fa-paperclip"></i>
|
||||
</a>
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
```
|
||||
|
||||
@ -260,6 +265,7 @@ hilbish.goro(fn)
|
||||
<i class="fas fa-paperclip"></i>
|
||||
</a>
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
```
|
||||
|
||||
@ -284,6 +290,7 @@ hilbish.highlighter(line)
|
||||
<i class="fas fa-paperclip"></i>
|
||||
</a>
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
```
|
||||
|
||||
@ -319,6 +326,7 @@ hilbish.hinter(line, pos)
|
||||
<i class="fas fa-paperclip"></i>
|
||||
</a>
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
```
|
||||
|
||||
@ -355,6 +363,7 @@ hilbish.inputMode(mode)
|
||||
<i class="fas fa-paperclip"></i>
|
||||
</a>
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
```
|
||||
|
||||
@ -378,6 +387,7 @@ hilbish.interval(cb, time) -> @Timer
|
||||
<i class="fas fa-paperclip"></i>
|
||||
</a>
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
```
|
||||
|
||||
@ -403,6 +413,7 @@ hilbish.multiprompt(str)
|
||||
<i class="fas fa-paperclip"></i>
|
||||
</a>
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
```
|
||||
|
||||
@ -444,6 +455,7 @@ hilbish.prependPath(dir)
|
||||
<i class="fas fa-paperclip"></i>
|
||||
</a>
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
```
|
||||
|
||||
@ -465,6 +477,7 @@ hilbish.prompt(str, typ)
|
||||
<i class="fas fa-paperclip"></i>
|
||||
</a>
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
```
|
||||
|
||||
@ -503,6 +516,7 @@ hilbish.read(prompt) -> input (string)
|
||||
<i class="fas fa-paperclip"></i>
|
||||
</a>
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
```
|
||||
|
||||
@ -526,6 +540,7 @@ hilbish.timeout(cb, time) -> @Timer
|
||||
<i class="fas fa-paperclip"></i>
|
||||
</a>
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
```
|
||||
|
||||
@ -551,6 +566,7 @@ hilbish.which(name) -> string
|
||||
<i class="fas fa-paperclip"></i>
|
||||
</a>
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
```
|
||||
|
||||
|
@ -22,8 +22,8 @@ is usable at `hilbish.editor`.
|
||||
<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() -> @Readline</a></td>
|
||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Creates a new readline instance.</td>
|
||||
<td class='p-3 font-medium text-black dark:text-white'><a href="#New">new() -> @Readline</a></td>
|
||||
<td class='p-3 font-medium text-black dark:text-white'>Creates a new readline instance.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@ -41,6 +41,7 @@ readline.new() -> @Readline
|
||||
<i class="fas fa-paperclip"></i>
|
||||
</a>
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
```
|
||||
|
||||
|
@ -21,8 +21,8 @@ Hilbish functions.
|
||||
<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>
|
||||
<td class='p-3 font-medium text-black dark:text-white'><a href="#new">new() -> @Snail</a></td>
|
||||
<td class='p-3 font-medium text-black dark:text-white'>Creates a new Snail instance.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@ -40,6 +40,7 @@ snail.new() -> @Snail
|
||||
<i class="fas fa-paperclip"></i>
|
||||
</a>
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,20 +18,20 @@ The terminal library is a simple and lower level library for certain terminal in
|
||||
<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>
|
||||
<td class='p-3 font-medium text-black dark:text-white'><a href="#restoreState">restoreState()</a></td>
|
||||
<td class='p-3 font-medium text-black 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>
|
||||
<td class='p-3 font-medium text-black dark:text-white'><a href="#saveState">saveState()</a></td>
|
||||
<td class='p-3 font-medium text-black 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>
|
||||
<td class='p-3 font-medium text-black dark:text-white'><a href="#setRaw">setRaw()</a></td>
|
||||
<td class='p-3 font-medium text-black 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>
|
||||
<td class='p-3 font-medium text-black dark:text-white'><a href="#size">size()</a></td>
|
||||
<td class='p-3 font-medium text-black dark:text-white'>Gets the dimensions of the terminal. Returns a table with `width` and `height`</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@ -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>
|
||||
|
||||
```
|
||||
|
||||
|
@ -30,8 +30,8 @@ t 'printing from another lua state!'
|
||||
<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="#thread">thread(fun) -> @Thread</a></td>
|
||||
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Creates a new, fresh Yarn thread.</td>
|
||||
<td class='p-3 font-medium text-black dark:text-white'><a href="#thread">thread(fun) -> @Thread</a></td>
|
||||
<td class='p-3 font-medium text-black dark:text-white'>Creates a new, fresh Yarn thread.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@ -49,6 +49,7 @@ yarn.thread(fun) -> @Thread
|
||||
<i class="fas fa-paperclip"></i>
|
||||
</a>
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
```
|
||||
|
||||
|
@ -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:
|
||||
|
||||
```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,25 +44,25 @@ const (
|
||||
type Recoverer func(event string, handler *Listener, err interface{})
|
||||
|
||||
// Listener is a struct that holds the handler for an event.
|
||||
type Listener struct{
|
||||
typ listenerType
|
||||
once bool
|
||||
caller func(...interface{}) rt.Value
|
||||
type Listener struct {
|
||||
typ listenerType
|
||||
once bool
|
||||
caller func(...interface{}) rt.Value
|
||||
luaCaller *rt.Closure
|
||||
}
|
||||
|
||||
type Bait struct{
|
||||
Loader packagelib.Loader
|
||||
type Bait struct {
|
||||
Loader packagelib.Loader
|
||||
recoverer Recoverer
|
||||
handlers map[string][]*Listener
|
||||
rtm *rt.Runtime
|
||||
handlers map[string][]*Listener
|
||||
rtm *rt.Runtime
|
||||
}
|
||||
|
||||
// New creates a new Bait instance.
|
||||
func New(rtm *rt.Runtime) *Bait {
|
||||
b := &Bait{
|
||||
handlers: make(map[string][]*Listener),
|
||||
rtm: rtm,
|
||||
rtm: rtm,
|
||||
}
|
||||
b.Loader = packagelib.Loader{
|
||||
Load: b.loaderFunc,
|
||||
@ -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)
|
||||
}
|
||||
@ -130,7 +132,7 @@ func (b *Bait) Emit(event string, args ...interface{}) []rt.Value {
|
||||
// On adds a Go function handler for an event.
|
||||
func (b *Bait) On(event string, handler func(...interface{}) rt.Value) *Listener {
|
||||
listener := &Listener{
|
||||
typ: goListener,
|
||||
typ: goListener,
|
||||
caller: handler,
|
||||
}
|
||||
|
||||
@ -141,7 +143,7 @@ func (b *Bait) On(event string, handler func(...interface{}) rt.Value) *Listener
|
||||
// OnLua adds a Lua function handler for an event.
|
||||
func (b *Bait) OnLua(event string, handler *rt.Closure) *Listener {
|
||||
listener := &Listener{
|
||||
typ: luaListener,
|
||||
typ: luaListener,
|
||||
luaCaller: handler,
|
||||
}
|
||||
b.addListener(event, listener)
|
||||
@ -174,8 +176,8 @@ func (b *Bait) OffLua(event string, handler *rt.Closure) {
|
||||
// Once adds a Go function listener for an event that only runs once.
|
||||
func (b *Bait) Once(event string, handler func(...interface{}) rt.Value) *Listener {
|
||||
listener := &Listener{
|
||||
typ: goListener,
|
||||
once: true,
|
||||
typ: goListener,
|
||||
once: true,
|
||||
caller: handler,
|
||||
}
|
||||
b.addListener(event, listener)
|
||||
@ -186,8 +188,8 @@ func (b *Bait) Once(event string, handler func(...interface{}) rt.Value) *Listen
|
||||
// OnceLua adds a Lua function listener for an event that only runs once.
|
||||
func (b *Bait) OnceLua(event string, handler *rt.Closure) *Listener {
|
||||
listener := &Listener{
|
||||
typ: luaListener,
|
||||
once: true,
|
||||
typ: luaListener,
|
||||
once: true,
|
||||
luaCaller: handler,
|
||||
}
|
||||
b.addListener(event, listener)
|
||||
@ -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{}) {
|
||||
@ -224,11 +225,11 @@ func (b *Bait) callRecoverer(event string, handler *Listener, err interface{}) {
|
||||
|
||||
func (b *Bait) loaderFunc(rtm *rt.Runtime) (rt.Value, func()) {
|
||||
exports := map[string]util.LuaExport{
|
||||
"catch": util.LuaExport{b.bcatch, 2, false},
|
||||
"catch": util.LuaExport{b.bcatch, 2, false},
|
||||
"catchOnce": util.LuaExport{b.bcatchOnce, 2, false},
|
||||
"throw": util.LuaExport{b.bthrow, 1, true},
|
||||
"release": util.LuaExport{b.brelease, 2, false},
|
||||
"hooks": util.LuaExport{b.bhooks, 1, false},
|
||||
"throw": util.LuaExport{b.bthrow, 1, true},
|
||||
"release": util.LuaExport{b.brelease, 2, false},
|
||||
"hooks": util.LuaExport{b.bhooks, 1, false},
|
||||
}
|
||||
mod := rt.NewTable()
|
||||
util.SetExports(rtm, mod, exports)
|
||||
@ -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 {
|
||||
|
@ -15,40 +15,35 @@ 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{
|
||||
Events *bait.Bait
|
||||
Loader packagelib.Loader
|
||||
type Commander struct {
|
||||
Events *bait.Bait
|
||||
Loader packagelib.Loader
|
||||
Commands map[string]*rt.Closure
|
||||
}
|
||||
|
||||
func New(rtm *rt.Runtime) *Commander {
|
||||
c := &Commander{
|
||||
Events: bait.New(rtm),
|
||||
Events: bait.New(rtm),
|
||||
Commands: make(map[string]*rt.Closure),
|
||||
}
|
||||
c.Loader = packagelib.Loader{
|
||||
@ -61,9 +56,9 @@ func New(rtm *rt.Runtime) *Commander {
|
||||
|
||||
func (c *Commander) loaderFunc(rtm *rt.Runtime) (rt.Value, func()) {
|
||||
exports := map[string]util.LuaExport{
|
||||
"register": util.LuaExport{c.cregister, 2, false},
|
||||
"register": util.LuaExport{c.cregister, 2, false},
|
||||
"deregister": util.LuaExport{c.cderegister, 1, false},
|
||||
"registry": util.LuaExport{c.cregistry, 0, false},
|
||||
"registry": util.LuaExport{c.cregistry, 0, false},
|
||||
}
|
||||
mod := rt.NewTable()
|
||||
util.SetExports(rtm, mod, exports)
|
||||
|
@ -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)
|
||||
|
@ -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(),
|
||||
]),
|
||||
// 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)
|
||||
],
|
||||
),
|
||||
]),
|
||||
@ -218,7 +224,8 @@ fn render_doc(md: String) {
|
||||
}
|
||||
|
||||
let margin = case level {
|
||||
1 -> "my-2"
|
||||
1 -> "my-4"
|
||||
2 -> "my-2"
|
||||
_ -> "my-1"
|
||||
}
|
||||
|
||||
|
@ -14,23 +14,26 @@ pub fn page() -> element.Element(a) {
|
||||
),
|
||||
],
|
||||
[
|
||||
html.div([attribute.class("gap-1 flex flex-col items-center")], [
|
||||
html.span(
|
||||
[attribute.class("flex flex-row items-center justify-center")],
|
||||
[
|
||||
html.img([
|
||||
attribute.src("./hilbish-flower.png"),
|
||||
attribute.class("h-20"),
|
||||
]),
|
||||
html.p([attribute.class("text-4xl font-bold")], [
|
||||
element.text("Hilbish"),
|
||||
]),
|
||||
],
|
||||
),
|
||||
html.p([attribute.class("text-6xl font-light")], [
|
||||
element.text("Something Unique."),
|
||||
]),
|
||||
]),
|
||||
html.div(
|
||||
[attribute.class("gap-1 flex flex-col items-center text-center")],
|
||||
[
|
||||
html.span(
|
||||
[attribute.class("flex flex-row items-center justify-center")],
|
||||
[
|
||||
html.img([
|
||||
attribute.src("./hilbish-flower.png"),
|
||||
attribute.class("h-20"),
|
||||
]),
|
||||
html.p([attribute.class("text-4xl font-bold")], [
|
||||
element.text("Hilbish"),
|
||||
]),
|
||||
],
|
||||
),
|
||||
html.p([attribute.class("text-6xl font-light")], [
|
||||
element.text("Something Unique."),
|
||||
]),
|
||||
],
|
||||
),
|
||||
html.p([attribute.class("text-center")], [
|
||||
element.text(
|
||||
"Hilbish is the new Moon-powered interactive shell for Lua fans!",
|
||||
@ -55,7 +58,7 @@ pub fn page() -> element.Element(a) {
|
||||
]),
|
||||
],
|
||||
),
|
||||
html.div([attribute.class("text-center")], [
|
||||
html.div([attribute.class("py-4 text-center border-b border-b-zinc-300")], [
|
||||
html.span(
|
||||
[
|
||||
attribute.class(
|
||||
@ -68,14 +71,14 @@ pub fn page() -> element.Element(a) {
|
||||
html.div(
|
||||
[
|
||||
attribute.class(
|
||||
"flex flex-col justify-center items-center gap-6 mt-4",
|
||||
"min-h-screen flex flex-col justify-around items-center gap-6",
|
||||
),
|
||||
],
|
||||
[
|
||||
html.h1(
|
||||
[
|
||||
attribute.class(
|
||||
"mt-3 text-5xl gap-2 font-bold inline-flex justify-center items-center",
|
||||
"mt-3 text-5xl gap-2 font-bold inline-flex flex-wrap justify-center items-center",
|
||||
),
|
||||
],
|
||||
[
|
||||
@ -133,7 +136,7 @@ pub fn page() -> element.Element(a) {
|
||||
html.div(
|
||||
[
|
||||
attribute.class(
|
||||
"border-t border-t-zinc-300 text-center bg-neutral-100 dark:bg-neutral-900 -mx-4 p-4",
|
||||
"-mx-4 px-4 py-8 -mt-4 text-center border-b border-b-zinc-300 bg-neutral-100 dark:bg-neutral-900",
|
||||
),
|
||||
],
|
||||
[
|
||||
@ -145,97 +148,102 @@ pub fn page() -> element.Element(a) {
|
||||
],
|
||||
[element.text("Download It Now!")],
|
||||
),
|
||||
html.div([attribute.class("flex flex-col items-center mt-4 gap-2")], [
|
||||
html.p([attribute.class("md:w-3/6")], [
|
||||
element.text(
|
||||
"To find out all that Hilbish can do, you should just try it out! It's officially available on Linux, MacOS, Windows, and probably builds on anything Go is available on!",
|
||||
),
|
||||
]),
|
||||
html.h2([attribute.class("text-3xl font-semibold")], [
|
||||
element.text("Featured Downloads"),
|
||||
]),
|
||||
html.p([], [
|
||||
element.text(
|
||||
"These are \"portable\" binary releases of Hilbish from GitHub. All the required files are in the archive. Put it somewhere, add the directory to your $PATH, and use Hilbish.",
|
||||
),
|
||||
]),
|
||||
html.div(
|
||||
[
|
||||
attribute.class(
|
||||
"mt-6 flex flex-row flex-wrap items-center justify-center gap-8",
|
||||
html.div(
|
||||
[attribute.class("h-full flex flex-col items-center mt-8 gap-6")],
|
||||
[
|
||||
html.p([attribute.class("md:w-3/6")], [
|
||||
element.text(
|
||||
"To find out all that Hilbish can do, you should just try it out! It's officially available on Linux, MacOS, Windows, and probably builds on anything Go is available on!",
|
||||
),
|
||||
],
|
||||
[
|
||||
html.div([attribute.class("flex flex-col gap-2")], [
|
||||
html.img([
|
||||
attribute.src(
|
||||
"https://upload.wikimedia.org/wikipedia/commons/thumb/3/35/Tux.svg/1200px-Tux.svg.png",
|
||||
),
|
||||
attribute.class("h-36"),
|
||||
]),
|
||||
button(
|
||||
"Linux (64-bit)",
|
||||
"bg-stone-500/30 hover:bg-stone-500/80",
|
||||
download_link("linux", "amd64"),
|
||||
]),
|
||||
html.div([attribute.class("sm:w-1/2 text-center")], [
|
||||
html.h2([attribute.class("text-3xl font-semibold")], [
|
||||
element.text("Featured Downloads"),
|
||||
]),
|
||||
html.p([], [
|
||||
element.text(
|
||||
"These are \"portable\" binary releases of Hilbish from GitHub. All the required files are in the archive. Put it somewhere, add the directory to your $PATH, and use Hilbish.",
|
||||
),
|
||||
]),
|
||||
html.div([attribute.class("flex flex-col gap-2")], [
|
||||
html.img([
|
||||
attribute.src(
|
||||
"https://upload.wikimedia.org/wikipedia/commons/thumb/0/0a/Unofficial_Windows_logo_variant_-_2002%E2%80%932012_%28Multicolored%29.svg/2321px-Unofficial_Windows_logo_variant_-_2002%E2%80%932012_%28Multicolored%29.svg.png",
|
||||
),
|
||||
attribute.class("h-36"),
|
||||
]),
|
||||
button(
|
||||
"Windows (64-bit)",
|
||||
"bg-stone-500/30 hover:bg-stone-500/80",
|
||||
download_link("windows", "amd64"),
|
||||
]),
|
||||
html.div(
|
||||
[
|
||||
attribute.class(
|
||||
"mt-6 flex flex-row flex-wrap items-center justify-center gap-8",
|
||||
),
|
||||
]),
|
||||
html.div(
|
||||
[
|
||||
attribute.class(
|
||||
"flex flex-col gap-2 justify-center items-center",
|
||||
),
|
||||
],
|
||||
[
|
||||
],
|
||||
[
|
||||
html.div([attribute.class("flex flex-col gap-2 items-center")], [
|
||||
html.img([
|
||||
attribute.src(
|
||||
"https://images.seeklogo.com/logo-png/38/2/apple-mac-os-logo-png_seeklogo-381401.png",
|
||||
"https://upload.wikimedia.org/wikipedia/commons/thumb/3/35/Tux.svg/1200px-Tux.svg.png",
|
||||
),
|
||||
attribute.class("h-36"),
|
||||
attribute.class("h-28 w-fit"),
|
||||
]),
|
||||
button(
|
||||
"MacOS (64-bit)",
|
||||
"Linux (64-bit)",
|
||||
"bg-stone-500/30 hover:bg-stone-500/80",
|
||||
download_link("darwin", "amd64"),
|
||||
download_link("linux", "amd64"),
|
||||
),
|
||||
],
|
||||
),
|
||||
html.div(
|
||||
[
|
||||
attribute.class(
|
||||
"flex flex-col gap-2 justify-center items-center",
|
||||
),
|
||||
],
|
||||
[
|
||||
]),
|
||||
html.div([attribute.class("flex flex-col gap-2 items-center")], [
|
||||
html.img([
|
||||
attribute.src(
|
||||
"https://images.seeklogo.com/logo-png/38/2/apple-mac-os-logo-png_seeklogo-381401.png",
|
||||
"https://upload.wikimedia.org/wikipedia/commons/thumb/0/0a/Unofficial_Windows_logo_variant_-_2002%E2%80%932012_%28Multicolored%29.svg/2321px-Unofficial_Windows_logo_variant_-_2002%E2%80%932012_%28Multicolored%29.svg.png",
|
||||
),
|
||||
attribute.class("h-36"),
|
||||
attribute.class("h-28 h-28 w-fit"),
|
||||
]),
|
||||
button(
|
||||
"MacOS (ARM)",
|
||||
"Windows (64-bit)",
|
||||
"bg-stone-500/30 hover:bg-stone-500/80",
|
||||
download_link("darwin", "arm64"),
|
||||
download_link("windows", "amd64"),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
util.link(conf.base_url_join("/install"), "Other Downloads", True),
|
||||
]),
|
||||
]),
|
||||
html.div(
|
||||
[
|
||||
attribute.class(
|
||||
"flex flex-col gap-2 justify-center items-center",
|
||||
),
|
||||
],
|
||||
[
|
||||
html.img([
|
||||
attribute.src(
|
||||
"https://images.seeklogo.com/logo-png/38/2/apple-mac-os-logo-png_seeklogo-381401.png",
|
||||
),
|
||||
attribute.class("h-28 h-28 w-fit"),
|
||||
]),
|
||||
button(
|
||||
"MacOS (64-bit)",
|
||||
"bg-stone-500/30 hover:bg-stone-500/80",
|
||||
download_link("darwin", "amd64"),
|
||||
),
|
||||
],
|
||||
),
|
||||
html.div(
|
||||
[
|
||||
attribute.class(
|
||||
"flex flex-col gap-2 justify-center items-center",
|
||||
),
|
||||
],
|
||||
[
|
||||
html.img([
|
||||
attribute.src(
|
||||
"https://images.seeklogo.com/logo-png/38/2/apple-mac-os-logo-png_seeklogo-381401.png",
|
||||
),
|
||||
attribute.class("h-28 h-28 w-fit"),
|
||||
]),
|
||||
button(
|
||||
"MacOS (ARM)",
|
||||
"bg-stone-500/30 hover:bg-stone-500/80",
|
||||
download_link("darwin", "arm64"),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
util.link(conf.base_url_join("/install"), "Other Downloads", True),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
])
|
||||
|
@ -4,6 +4,7 @@ import gleam/option
|
||||
pub type Post {
|
||||
Post(
|
||||
name: String,
|
||||
description: String,
|
||||
title: String,
|
||||
slug: String,
|
||||
metadata: option.Option(glaml.Document),
|
||||
|
@ -6,6 +6,7 @@ import lustre/attribute
|
||||
import lustre/element
|
||||
import lustre/element/html
|
||||
|
||||
import conf
|
||||
import glaml
|
||||
import post
|
||||
|
||||
@ -68,3 +69,77 @@ 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(conf.base_url_join("/")),
|
||||
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),
|
||||
]),
|
||||
],
|
||||
)
|
||||
}
|
||||
|
@ -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()
|
||||
},
|
||||
]),
|
||||
],
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user