mirror of https://github.com/Hilbis/Hilbish
Compare commits
7 Commits
688552f029
...
dea1f7d008
Author | SHA1 | Date |
---|---|---|
sammyette | dea1f7d008 | |
sammyette | 95ac2e280d | |
sammyette | 7fd2ed391b | |
sammyette | 0900284304 | |
sammyette | eda4fda972 | |
sammyette | 22cf0fcb49 | |
sammyette | aa7e899db4 |
2
api.go
2
api.go
|
@ -9,7 +9,7 @@
|
||||||
// #field interactive Is Hilbish in an interactive shell?
|
// #field interactive Is Hilbish in an interactive shell?
|
||||||
// #field login Is Hilbish the login shell?
|
// #field login Is Hilbish the login shell?
|
||||||
// #field vimMode Current Vim input mode of Hilbish (will be nil if not in Vim input mode)
|
// #field vimMode Current Vim input mode of Hilbish (will be nil if not in Vim input mode)
|
||||||
// #field exitCode xit code of the last executed command
|
// #field exitCode Exit code of the last executed command
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
@ -11,6 +11,8 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"os"
|
"os"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
md "github.com/atsushinee/go-markdown-generator/doc"
|
||||||
)
|
)
|
||||||
|
|
||||||
var header = `---
|
var header = `---
|
||||||
|
@ -448,22 +450,63 @@ func main() {
|
||||||
return fmt.Sprintf(`<a href="%s" style="text-decoration: none;">%s</a>`, linkedTyp, typName)
|
return fmt.Sprintf(`<a href="%s" style="text-decoration: none;">%s</a>`, linkedTyp, typName)
|
||||||
})
|
})
|
||||||
f.WriteString(fmt.Sprintf("## Introduction\n%s\n\n", modDescription))
|
f.WriteString(fmt.Sprintf("## Introduction\n%s\n\n", modDescription))
|
||||||
if len(modu.Fields) != 0 {
|
if len(modu.Docs) != 0 {
|
||||||
f.WriteString("## Interface fields\n")
|
funcCount := 0
|
||||||
for _, dps := range modu.Fields {
|
for _, dps := range modu.Docs {
|
||||||
f.WriteString(fmt.Sprintf("- `%s`: ", dps.FuncName))
|
if dps.IsMember {
|
||||||
f.WriteString(strings.Join(dps.Doc, " "))
|
continue
|
||||||
f.WriteString("\n")
|
}
|
||||||
|
funcCount++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
f.WriteString("## Functions\n")
|
||||||
|
|
||||||
|
mdTable := md.NewTable(funcCount, 2)
|
||||||
|
mdTable.SetTitle(0, "")
|
||||||
|
mdTable.SetTitle(1, "")
|
||||||
|
|
||||||
|
diff := 0
|
||||||
|
for i, dps := range modu.Docs {
|
||||||
|
if dps.IsMember {
|
||||||
|
diff++
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
mdTable.SetContent(i - diff, 0, fmt.Sprintf(`<a href="#%s">%s</a>`, dps.FuncName, dps.FuncSig))
|
||||||
|
mdTable.SetContent(i - diff, 1, dps.Doc[0])
|
||||||
|
}
|
||||||
|
f.WriteString(mdTable.String())
|
||||||
|
f.WriteString("\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(modu.Fields) != 0 {
|
||||||
|
f.WriteString("## Static module fields\n")
|
||||||
|
|
||||||
|
mdTable := md.NewTable(len(modu.Fields), 2)
|
||||||
|
mdTable.SetTitle(0, "")
|
||||||
|
mdTable.SetTitle(1, "")
|
||||||
|
|
||||||
|
|
||||||
|
for i, dps := range modu.Fields {
|
||||||
|
mdTable.SetContent(i, 0, dps.FuncName)
|
||||||
|
mdTable.SetContent(i, 1, strings.Join(dps.Doc, " "))
|
||||||
|
}
|
||||||
|
f.WriteString(mdTable.String())
|
||||||
f.WriteString("\n")
|
f.WriteString("\n")
|
||||||
}
|
}
|
||||||
if len(modu.Properties) != 0 {
|
if len(modu.Properties) != 0 {
|
||||||
f.WriteString("## Object properties\n")
|
f.WriteString("## Object properties\n")
|
||||||
for _, dps := range modu.Properties {
|
|
||||||
f.WriteString(fmt.Sprintf("- `%s`: ", dps.FuncName))
|
mdTable := md.NewTable(len(modu.Fields), 2)
|
||||||
f.WriteString(strings.Join(dps.Doc, " "))
|
mdTable.SetTitle(0, "")
|
||||||
f.WriteString("\n")
|
mdTable.SetTitle(1, "")
|
||||||
|
|
||||||
|
|
||||||
|
for i, dps := range modu.Properties {
|
||||||
|
mdTable.SetContent(i, 0, dps.FuncName)
|
||||||
|
mdTable.SetContent(i, 1, strings.Join(dps.Doc, " "))
|
||||||
}
|
}
|
||||||
|
f.WriteString(mdTable.String())
|
||||||
f.WriteString("\n")
|
f.WriteString("\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -473,6 +516,7 @@ func main() {
|
||||||
if dps.IsMember {
|
if dps.IsMember {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
f.WriteString(fmt.Sprintf("<hr><div id='%s'>", dps.FuncName))
|
||||||
htmlSig := typeTag.ReplaceAllStringFunc(strings.Replace(modname + "." + dps.FuncSig, "<", `\<`, -1), func(typ string) string {
|
htmlSig := typeTag.ReplaceAllStringFunc(strings.Replace(modname + "." + dps.FuncSig, "<", `\<`, -1), func(typ string) string {
|
||||||
typName := typ[1:]
|
typName := typ[1:]
|
||||||
typLookup := typeTable[strings.ToLower(typName)]
|
typLookup := typeTable[strings.ToLower(typName)]
|
||||||
|
@ -483,7 +527,15 @@ func main() {
|
||||||
linkedTyp := fmt.Sprintf("/Hilbish/docs/api/%s/%s#%s", typLookup[0], ifaces, strings.ToLower(typName))
|
linkedTyp := fmt.Sprintf("/Hilbish/docs/api/%s/%s#%s", typLookup[0], ifaces, strings.ToLower(typName))
|
||||||
return fmt.Sprintf(`<a href="%s" style="text-decoration: none;" id="lol">%s</a>`, linkedTyp, typName)
|
return fmt.Sprintf(`<a href="%s" style="text-decoration: none;" id="lol">%s</a>`, linkedTyp, typName)
|
||||||
})
|
})
|
||||||
f.WriteString(fmt.Sprintf("### %s\n", htmlSig))
|
f.WriteString(fmt.Sprintf(`
|
||||||
|
<h4 class='heading'>
|
||||||
|
%s
|
||||||
|
<a href="#%s" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
`, htmlSig, dps.FuncName))
|
||||||
for _, doc := range dps.Doc {
|
for _, doc := range dps.Doc {
|
||||||
if !strings.HasPrefix(doc, "---") {
|
if !strings.HasPrefix(doc, "---") {
|
||||||
f.WriteString(doc + "\n")
|
f.WriteString(doc + "\n")
|
||||||
|
@ -509,13 +561,15 @@ func main() {
|
||||||
f.WriteString(strings.Join(p.Doc, " "))
|
f.WriteString(strings.Join(p.Doc, " "))
|
||||||
f.WriteString("\n\n")
|
f.WriteString("\n\n")
|
||||||
}
|
}
|
||||||
f.WriteString("\n")
|
f.WriteString("</div>")
|
||||||
|
f.WriteString("\n\n")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(modu.Types) != 0 {
|
if len(modu.Types) != 0 {
|
||||||
f.WriteString("## Types\n")
|
f.WriteString("## Types\n")
|
||||||
for _, dps := range modu.Types {
|
for _, dps := range modu.Types {
|
||||||
|
f.WriteString("<hr>\n\n")
|
||||||
f.WriteString(fmt.Sprintf("## %s\n", dps.FuncName))
|
f.WriteString(fmt.Sprintf("## %s\n", dps.FuncName))
|
||||||
for _, doc := range dps.Doc {
|
for _, doc := range dps.Doc {
|
||||||
if !strings.HasPrefix(doc, "---") {
|
if !strings.HasPrefix(doc, "---") {
|
||||||
|
@ -523,12 +577,18 @@ func main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(dps.Properties) != 0 {
|
if len(dps.Properties) != 0 {
|
||||||
f.WriteString("### Properties\n")
|
f.WriteString("## Object properties\n")
|
||||||
for _, dps := range dps.Properties {
|
|
||||||
f.WriteString(fmt.Sprintf("- `%s`: ", dps.FuncName))
|
mdTable := md.NewTable(len(dps.Properties), 2)
|
||||||
f.WriteString(strings.Join(dps.Doc, " "))
|
mdTable.SetTitle(0, "")
|
||||||
f.WriteString("\n")
|
mdTable.SetTitle(1, "")
|
||||||
|
|
||||||
|
for i, d := range dps.Properties {
|
||||||
|
mdTable.SetContent(i, 0, d.FuncName)
|
||||||
|
mdTable.SetContent(i, 1, strings.Join(d.Doc, " "))
|
||||||
}
|
}
|
||||||
|
f.WriteString(mdTable.String())
|
||||||
|
f.WriteString("\n")
|
||||||
}
|
}
|
||||||
f.WriteString("\n")
|
f.WriteString("\n")
|
||||||
f.WriteString("### Methods\n")
|
f.WriteString("### Methods\n")
|
||||||
|
|
|
@ -21,7 +21,7 @@ You can act on events via callback functions.
|
||||||
|
|
||||||
Examples of this are in the Hilbish default config!
|
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)
|
bait.catch('command.exit', function(code)
|
||||||
running = false
|
running = false
|
||||||
doPrompt(code ~= 0)
|
doPrompt(code ~= 0)
|
||||||
|
@ -33,31 +33,82 @@ What this does is, whenever the `command.exit` event is thrown,
|
||||||
this function will set the user prompt.
|
this function will set the user prompt.
|
||||||
|
|
||||||
## Functions
|
## Functions
|
||||||
### bait.catch(name, cb)
|
|||
|
||||||
|
|----|----|
|
||||||
|
|<a href="#catch">catch(name, cb)</a>|Catches a hook with `name`. Runs the `cb` when it is thrown|
|
||||||
|
|<a href="#catchOnce">catchOnce(name, cb)</a>|Same as catch, but only runs the `cb` once and then removes the hook|
|
||||||
|
|<a href="#hooks">hooks(name) -> table</a>|Returns a table with hooks (callback functions) on the event with `name`.|
|
||||||
|
|<a href="#release">release(name, catcher)</a>|Removes the `catcher` for the event with `name`.|
|
||||||
|
|<a href="#throw">throw(name, ...args)</a>|Throws a hook with `name` with the provided `args`|
|
||||||
|
|
||||||
|
## Functions
|
||||||
|
<hr><div id='catch'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
bait.catch(name, cb)
|
||||||
|
<a href="#catch" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
Catches a hook with `name`. Runs the `cb` when it is thrown
|
Catches a hook with `name`. Runs the `cb` when it is thrown
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`string` **`name`**
|
`string` **`name`**
|
||||||
ummm
|
ummm
|
||||||
|
|
||||||
|
`function` **`cb`**
|
||||||
|
?
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='catchOnce'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
bait.catchOnce(name, cb)
|
||||||
|
<a href="#catchOnce" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### bait.catchOnce(name, cb)
|
|
||||||
Same as catch, but only runs the `cb` once and then removes the hook
|
Same as catch, but only runs the `cb` once and then removes the hook
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='hooks'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
bait.hooks(name) -> table
|
||||||
|
<a href="#hooks" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### bait.hooks(name) -> table
|
|
||||||
Returns a table with hooks (callback functions) on the event with `name`.
|
Returns a table with hooks (callback functions) on the event with `name`.
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='release'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
bait.release(name, catcher)
|
||||||
|
<a href="#release" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### bait.release(name, catcher)
|
|
||||||
Removes the `catcher` for the event with `name`.
|
Removes the `catcher` for the event with `name`.
|
||||||
For this to work, `catcher` has to be the same function used to catch
|
For this to work, `catcher` has to be the same function used to catch
|
||||||
an event, like one saved to a variable.
|
an event, like one saved to a variable.
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='throw'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
bait.throw(name, ...args)
|
||||||
|
<a href="#throw" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### bait.throw(name, ...args)
|
|
||||||
Throws a hook with `name` with the provided `args`
|
Throws a hook with `name` with the provided `args`
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`string` **`name`**
|
`string` **`name`**
|
||||||
|
@ -66,4 +117,5 @@ The name of the hook.
|
||||||
`any` **`args`** (This type is variadic. You can pass an infinite amount of parameters with this type.)
|
`any` **`args`** (This type is variadic. You can pass an infinite amount of parameters with this type.)
|
||||||
The arguments to pass to the hook.
|
The arguments to pass to the hook.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -31,20 +31,42 @@ The `sinks` parameter is a table with 3 keys: `in`, `out`,
|
||||||
and `err`. The values of these is a <a href="/Hilbish/docs/api/hilbish/#sink" style="text-decoration: none;">Sink</a>.
|
and `err`. The values of these is a <a href="/Hilbish/docs/api/hilbish/#sink" style="text-decoration: none;">Sink</a>.
|
||||||
|
|
||||||
- `in` is the standard input. You can read from this sink
|
- `in` is the standard input. You can read from this sink
|
||||||
to get user input. (**This is currently unimplemented.**)
|
to get user input.
|
||||||
- `out` is standard output. This is usually where text meant for
|
- `out` is standard output. This is usually where text meant for
|
||||||
output should go.
|
output should go.
|
||||||
- `err` is standard error. This sink is for writing errors, as the
|
- `err` is standard error. This sink is for writing errors, as the
|
||||||
name would suggest.
|
name would suggest.
|
||||||
|
|
||||||
## Functions
|
## Functions
|
||||||
### commander.deregister(name)
|
|||
|
||||||
|
|----|----|
|
||||||
|
|<a href="#deregister">deregister(name)</a>|Deregisters any command registered with `name`|
|
||||||
|
|<a href="#register">register(name, cb)</a>|Register a command with `name` that runs `cb` when ran|
|
||||||
|
|
||||||
|
## Functions
|
||||||
|
<hr><div id='deregister'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
commander.deregister(name)
|
||||||
|
<a href="#deregister" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
Deregisters any command registered with `name`
|
Deregisters any command registered with `name`
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='register'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
commander.register(name, cb)
|
||||||
|
<a href="#register" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### commander.register(name, cb)
|
|
||||||
Register a command with `name` that runs `cb` when ran
|
Register a command with `name` that runs `cb` when ran
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
103
docs/api/fs.md
103
docs/api/fs.md
|
@ -13,51 +13,135 @@ and other things, and acts an addition to the Lua standard library's
|
||||||
I/O and filesystem functions.
|
I/O and filesystem functions.
|
||||||
|
|
||||||
## Functions
|
## Functions
|
||||||
### fs.abs(path) -> string
|
|||
|
||||||
|
|----|----|
|
||||||
|
|<a href="#abs">abs(path) -> string</a>|Gives an absolute version of `path`.|
|
||||||
|
|<a href="#basename">basename(path) -> string</a>|Gives the basename of `path`. For the rules,|
|
||||||
|
|<a href="#cd">cd(dir)</a>|Changes directory to `dir`|
|
||||||
|
|<a href="#dir">dir(path) -> string</a>|Returns the directory part of `path`. For the rules, see Go's|
|
||||||
|
|<a href="#glob">glob(pattern) -> matches (table)</a>|Glob all files and directories that match the pattern.|
|
||||||
|
|<a href="#join">join(...) -> string</a>|Takes paths and joins them together with the OS's|
|
||||||
|
|<a href="#mkdir">mkdir(name, recursive)</a>|Makes a directory called `name`. If `recursive` is true, it will create its parent directories.|
|
||||||
|
|<a href="#readdir">readdir(dir) -> {}</a>|Returns a table of files in `dir`.|
|
||||||
|
|<a href="#stat">stat(path) -> {}</a>|Returns a table of info about the `path`.|
|
||||||
|
|
||||||
|
## Functions
|
||||||
|
<hr><div id='abs'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
fs.abs(path) -> string
|
||||||
|
<a href="#abs" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
Gives an absolute version of `path`.
|
Gives an absolute version of `path`.
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='basename'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
fs.basename(path) -> string
|
||||||
|
<a href="#basename" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### fs.basename(path) -> string
|
|
||||||
Gives the basename of `path`. For the rules,
|
Gives the basename of `path`. For the rules,
|
||||||
see Go's filepath.Base
|
see Go's filepath.Base
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='cd'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
fs.cd(dir)
|
||||||
|
<a href="#cd" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### fs.cd(dir)
|
|
||||||
Changes directory to `dir`
|
Changes directory to `dir`
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='dir'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
fs.dir(path) -> string
|
||||||
|
<a href="#dir" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### fs.dir(path) -> string
|
|
||||||
Returns the directory part of `path`. For the rules, see Go's
|
Returns the directory part of `path`. For the rules, see Go's
|
||||||
filepath.Dir
|
filepath.Dir
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='glob'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
fs.glob(pattern) -> matches (table)
|
||||||
|
<a href="#glob" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### fs.glob(pattern) -> matches (table)
|
|
||||||
Glob all files and directories that match the pattern.
|
Glob all files and directories that match the pattern.
|
||||||
For the rules, see Go's filepath.Glob
|
For the rules, see Go's filepath.Glob
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='join'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
fs.join(...) -> string
|
||||||
|
<a href="#join" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### fs.join(...) -> string
|
|
||||||
Takes paths and joins them together with the OS's
|
Takes paths and joins them together with the OS's
|
||||||
directory separator (forward or backward slash).
|
directory separator (forward or backward slash).
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='mkdir'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
fs.mkdir(name, recursive)
|
||||||
|
<a href="#mkdir" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### fs.mkdir(name, recursive)
|
|
||||||
Makes a directory called `name`. If `recursive` is true, it will create its parent directories.
|
Makes a directory called `name`. If `recursive` is true, it will create its parent directories.
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='readdir'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
fs.readdir(dir) -> {}
|
||||||
|
<a href="#readdir" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### fs.readdir(dir) -> {}
|
|
||||||
Returns a table of files in `dir`.
|
Returns a table of files in `dir`.
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='stat'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
fs.stat(path) -> {}
|
||||||
|
<a href="#stat" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### fs.stat(path) -> {}
|
|
||||||
Returns a table of info about the `path`.
|
Returns a table of info about the `path`.
|
||||||
It contains the following keys:
|
It contains the following keys:
|
||||||
name (string) - Name of the path
|
name (string) - Name of the path
|
||||||
|
@ -66,4 +150,5 @@ mode (string) - Permission mode in an octal format string (with leading 0)
|
||||||
isDir (boolean) - If the path is a directory
|
isDir (boolean) - If the path is a directory
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -11,29 +11,76 @@ menu:
|
||||||
The Hilbish module includes the core API, containing
|
The Hilbish module includes the core API, containing
|
||||||
interfaces and functions which directly relate to shell functionality.
|
interfaces and functions which directly relate to shell functionality.
|
||||||
|
|
||||||
## Interface fields
|
## Functions
|
||||||
- `ver`: The version of Hilbish
|
|||
|
||||||
- `goVersion`: The version of Go that Hilbish was compiled with
|
|----|----|
|
||||||
- `user`: Username of the user
|
|<a href="#alias">alias(cmd, orig)</a>|Sets an alias of `cmd` to `orig`|
|
||||||
- `host`: Hostname of the machine
|
|<a href="#appendPath">appendPath(dir)</a>|Appends `dir` to $PATH|
|
||||||
- `dataDir`: Directory for Hilbish data files, including the docs and default modules
|
|<a href="#complete">complete(scope, cb)</a>|Registers a completion handler for `scope`.|
|
||||||
- `interactive`: Is Hilbish in an interactive shell?
|
|<a href="#cwd">cwd() -> string</a>|Returns the current directory of the shell|
|
||||||
- `login`: Is Hilbish the login shell?
|
|<a href="#exec">exec(cmd)</a>|Replaces running hilbish with `cmd`|
|
||||||
- `vimMode`: Current Vim input mode of Hilbish (will be nil if not in Vim input mode)
|
|<a href="#goro">goro(fn)</a>|Puts `fn` in a goroutine|
|
||||||
- `exitCode`: xit code of the last executed command
|
|<a href="#highlighter">highlighter(line)</a>|Line highlighter handler. This is mainly for syntax highlighting, but in|
|
||||||
|
|<a href="#hinter">hinter(line, pos)</a>|The command line hint handler. It gets called on every key insert to|
|
||||||
|
|<a href="#inputMode">inputMode(mode)</a>|Sets the input mode for Hilbish's line reader. Accepts either emacs or vim|
|
||||||
|
|<a href="#interval">interval(cb, time) -> @Timer</a>|Runs the `cb` function every `time` milliseconds.|
|
||||||
|
|<a href="#multiprompt">multiprompt(str)</a>|Changes the continued line prompt to `str`|
|
||||||
|
|<a href="#prependPath">prependPath(dir)</a>|Prepends `dir` to $PATH|
|
||||||
|
|<a href="#prompt">prompt(str, typ)</a>|Changes the shell prompt to `str`|
|
||||||
|
|<a href="#read">read(prompt) -> input (string)</a>|Read input from the user, using Hilbish's line editor/input reader.|
|
||||||
|
|<a href="#run">run(cmd, returnOut) -> exitCode (number), stdout (string), stderr (string)</a>|Runs `cmd` in Hilbish's sh interpreter.|
|
||||||
|
|<a href="#runnerMode">runnerMode(mode)</a>|Sets the execution/runner mode for interactive Hilbish. This determines whether|
|
||||||
|
|<a href="#timeout">timeout(cb, time) -> @Timer</a>|Runs the `cb` function after `time` in milliseconds.|
|
||||||
|
|<a href="#which">which(name) -> string</a>|Checks if `name` is a valid command.|
|
||||||
|
|
||||||
|
## Static module fields
|
||||||
|
|||
|
||||||
|
|----|----|
|
||||||
|
|ver|The version of Hilbish|
|
||||||
|
|goVersion|The version of Go that Hilbish was compiled with|
|
||||||
|
|user|Username of the user|
|
||||||
|
|host|Hostname of the machine|
|
||||||
|
|dataDir|Directory for Hilbish data files, including the docs and default modules|
|
||||||
|
|interactive|Is Hilbish in an interactive shell?|
|
||||||
|
|login|Is Hilbish the login shell?|
|
||||||
|
|vimMode|Current Vim input mode of Hilbish (will be nil if not in Vim input mode)|
|
||||||
|
|exitCode|xit code of the last executed command|
|
||||||
|
|
||||||
## Functions
|
## Functions
|
||||||
### hilbish.alias(cmd, orig)
|
<hr><div id='alias'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.alias(cmd, orig)
|
||||||
|
<a href="#alias" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
Sets an alias of `cmd` to `orig`
|
Sets an alias of `cmd` to `orig`
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='appendPath'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.appendPath(dir)
|
||||||
|
<a href="#appendPath" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### hilbish.appendPath(dir)
|
|
||||||
Appends `dir` to $PATH
|
Appends `dir` to $PATH
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='complete'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.complete(scope, cb)
|
||||||
|
<a href="#complete" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### hilbish.complete(scope, cb)
|
|
||||||
Registers a completion handler for `scope`.
|
Registers a completion handler for `scope`.
|
||||||
A `scope` is currently only expected to be `command.<cmd>`,
|
A `scope` is currently only expected to be `command.<cmd>`,
|
||||||
replacing <cmd> with the name of the command (for example `command.git`).
|
replacing <cmd> with the name of the command (for example `command.git`).
|
||||||
|
@ -41,23 +88,55 @@ replacing <cmd> with the name of the command (for example `command.git`).
|
||||||
Check `doc completions` for more information.
|
Check `doc completions` for more information.
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='cwd'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.cwd() -> string
|
||||||
|
<a href="#cwd" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### hilbish.cwd() -> string
|
|
||||||
Returns the current directory of the shell
|
Returns the current directory of the shell
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='exec'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.exec(cmd)
|
||||||
|
<a href="#exec" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### hilbish.exec(cmd)
|
|
||||||
Replaces running hilbish with `cmd`
|
Replaces running hilbish with `cmd`
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='goro'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.goro(fn)
|
||||||
|
<a href="#goro" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### hilbish.goro(fn)
|
|
||||||
Puts `fn` in a goroutine
|
Puts `fn` in a goroutine
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='highlighter'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.highlighter(line)
|
||||||
|
<a href="#highlighter" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### hilbish.highlighter(line)
|
|
||||||
Line highlighter handler. This is mainly for syntax highlighting, but in
|
Line highlighter handler. This is mainly for syntax highlighting, but in
|
||||||
reality could set the input of the prompt to *display* anything. The
|
reality could set the input of the prompt to *display* anything. The
|
||||||
callback is passed the current line and is expected to return a line that
|
callback is passed the current line and is expected to return a line that
|
||||||
|
@ -72,8 +151,16 @@ end
|
||||||
This code will highlight all double quoted strings in green.
|
This code will highlight all double quoted strings in green.
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='hinter'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.hinter(line, pos)
|
||||||
|
<a href="#hinter" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### hilbish.hinter(line, pos)
|
|
||||||
The command line hint handler. It gets called on every key insert to
|
The command line hint handler. It gets called on every key insert to
|
||||||
determine what text to use as an inline hint. It is passed the current
|
determine what text to use as an inline hint. It is passed the current
|
||||||
line and cursor position. It is expected to return a string which is used
|
line and cursor position. It is expected to return a string which is used
|
||||||
|
@ -81,29 +168,69 @@ as the text for the hint. This is by default a shim. To set hints,
|
||||||
override this function with your custom handler.
|
override this function with your custom handler.
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='inputMode'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.inputMode(mode)
|
||||||
|
<a href="#inputMode" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### hilbish.inputMode(mode)
|
|
||||||
Sets the input mode for Hilbish's line reader. Accepts either emacs or vim
|
Sets the input mode for Hilbish's line reader. Accepts either emacs or vim
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='interval'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.interval(cb, time) -> <a href="/Hilbish/docs/api/hilbish/hilbish.timers/#timer" style="text-decoration: none;" id="lol">Timer</a>
|
||||||
|
<a href="#interval" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### hilbish.interval(cb, time) -> <a href="/Hilbish/docs/api/hilbish/hilbish.timers/#timer" style="text-decoration: none;" id="lol">Timer</a>
|
|
||||||
Runs the `cb` function every `time` milliseconds.
|
Runs the `cb` function every `time` milliseconds.
|
||||||
This creates a timer that starts immediately.
|
This creates a timer that starts immediately.
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='multiprompt'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.multiprompt(str)
|
||||||
|
<a href="#multiprompt" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### hilbish.multiprompt(str)
|
|
||||||
Changes the continued line prompt to `str`
|
Changes the continued line prompt to `str`
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='prependPath'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.prependPath(dir)
|
||||||
|
<a href="#prependPath" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### hilbish.prependPath(dir)
|
|
||||||
Prepends `dir` to $PATH
|
Prepends `dir` to $PATH
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='prompt'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.prompt(str, typ)
|
||||||
|
<a href="#prompt" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### hilbish.prompt(str, typ)
|
|
||||||
Changes the shell prompt to `str`
|
Changes the shell prompt to `str`
|
||||||
There are a few verbs that can be used in the prompt text.
|
There are a few verbs that can be used in the prompt text.
|
||||||
These will be formatted and replaced with the appropriate values.
|
These will be formatted and replaced with the appropriate values.
|
||||||
|
@ -112,22 +239,46 @@ These will be formatted and replaced with the appropriate values.
|
||||||
`%h` - Hostname of device
|
`%h` - Hostname of device
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='read'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.read(prompt) -> input (string)
|
||||||
|
<a href="#read" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### hilbish.read(prompt) -> input (string)
|
|
||||||
Read input from the user, using Hilbish's line editor/input reader.
|
Read input from the user, using Hilbish's line editor/input reader.
|
||||||
This is a separate instance from the one Hilbish actually uses.
|
This is a separate instance from the one Hilbish actually uses.
|
||||||
Returns `input`, will be nil if ctrl + d is pressed, or an error occurs (which shouldn't happen)
|
Returns `input`, will be nil if ctrl + d is pressed, or an error occurs (which shouldn't happen)
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='run'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.run(cmd, returnOut) -> exitCode (number), stdout (string), stderr (string)
|
||||||
|
<a href="#run" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### hilbish.run(cmd, returnOut) -> exitCode (number), stdout (string), stderr (string)
|
|
||||||
Runs `cmd` in Hilbish's sh interpreter.
|
Runs `cmd` in Hilbish's sh interpreter.
|
||||||
If returnOut is true, the outputs of `cmd` will be returned as the 2nd and
|
If returnOut is true, the outputs of `cmd` will be returned as the 2nd and
|
||||||
3rd values instead of being outputted to the terminal.
|
3rd values instead of being outputted to the terminal.
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='runnerMode'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.runnerMode(mode)
|
||||||
|
<a href="#runnerMode" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### hilbish.runnerMode(mode)
|
|
||||||
Sets the execution/runner mode for interactive Hilbish. This determines whether
|
Sets the execution/runner mode for interactive Hilbish. This determines whether
|
||||||
Hilbish wll try to run input as Lua and/or sh or only do one of either.
|
Hilbish wll try to run input as Lua and/or sh or only do one of either.
|
||||||
Accepted values for mode are hybrid (the default), hybridRev (sh first then Lua),
|
Accepted values for mode are hybrid (the default), hybridRev (sh first then Lua),
|
||||||
|
@ -135,20 +286,39 @@ sh, and lua. It also accepts a function, to which if it is passed one
|
||||||
will call it to execute user input instead.
|
will call it to execute user input instead.
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='timeout'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.timeout(cb, time) -> <a href="/Hilbish/docs/api/hilbish/hilbish.timers/#timer" style="text-decoration: none;" id="lol">Timer</a>
|
||||||
|
<a href="#timeout" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### hilbish.timeout(cb, time) -> <a href="/Hilbish/docs/api/hilbish/hilbish.timers/#timer" style="text-decoration: none;" id="lol">Timer</a>
|
|
||||||
Runs the `cb` function after `time` in milliseconds.
|
Runs the `cb` function after `time` in milliseconds.
|
||||||
This creates a timer that starts immediately.
|
This creates a timer that starts immediately.
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='which'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.which(name) -> string
|
||||||
|
<a href="#which" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### hilbish.which(name) -> string
|
|
||||||
Checks if `name` is a valid command.
|
Checks if `name` is a valid command.
|
||||||
Will return the path of the binary, or a basename if it's a commander.
|
Will return the path of the binary, or a basename if it's a commander.
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
## Types
|
## Types
|
||||||
|
<hr>
|
||||||
|
|
||||||
## Sink
|
## Sink
|
||||||
A sink is a structure that has input and/or output to/from
|
A sink is a structure that has input and/or output to/from
|
||||||
a desination.
|
a desination.
|
||||||
|
|
|
@ -11,23 +11,63 @@ menu:
|
||||||
The alias interface deals with all command aliases in Hilbish.
|
The alias interface deals with all command aliases in Hilbish.
|
||||||
|
|
||||||
## Functions
|
## Functions
|
||||||
### hilbish.aliases.add(alias, cmd)
|
|||
|
||||||
|
|----|----|
|
||||||
|
|<a href="#aliases.add">add(alias, cmd)</a>|This is an alias (ha) for the `hilbish.alias` function.|
|
||||||
|
|<a href="#aliases.delete">delete(name)</a>|Removes an alias.|
|
||||||
|
|<a href="#aliases.list">list() -> table<string, string></a>|Get a table of all aliases, with string keys as the alias and the value as the command.|
|
||||||
|
|<a href="#aliases.resolve">resolve(alias) -> command (string)</a>|Tries to resolve an alias to its command.|
|
||||||
|
|
||||||
|
## Functions
|
||||||
|
<hr><div id='aliases.add'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.aliases.add(alias, cmd)
|
||||||
|
<a href="#aliases.add" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
This is an alias (ha) for the `hilbish.alias` function.
|
This is an alias (ha) for the `hilbish.alias` function.
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='aliases.delete'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.aliases.delete(name)
|
||||||
|
<a href="#aliases.delete" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### hilbish.aliases.delete(name)
|
|
||||||
Removes an alias.
|
Removes an alias.
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='aliases.list'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.aliases.list() -> table\<string, string>
|
||||||
|
<a href="#aliases.list" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### hilbish.aliases.list() -> table\<string, string>
|
|
||||||
Get a table of all aliases, with string keys as the alias and the value as the command.
|
Get a table of all aliases, with string keys as the alias and the value as the command.
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='aliases.resolve'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.aliases.resolve(alias) -> command (string)
|
||||||
|
<a href="#aliases.resolve" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### hilbish.aliases.resolve(alias) -> command (string)
|
|
||||||
Tries to resolve an alias to its command.
|
Tries to resolve an alias to its command.
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -11,27 +11,67 @@ menu:
|
||||||
The completions interface deals with tab completions.
|
The completions interface deals with tab completions.
|
||||||
|
|
||||||
## Functions
|
## Functions
|
||||||
### hilbish.completions.call(name, query, ctx, fields) -> completionGroups (table), prefix (string)
|
|||
|
||||||
|
|----|----|
|
||||||
|
|<a href="#completions.call">call(name, query, ctx, fields) -> completionGroups (table), prefix (string)</a>|Calls a completer function. This is mainly used to call|
|
||||||
|
|<a href="#completions.handler">handler(line, pos)</a>|The handler function is the callback for tab completion in Hilbish.|
|
||||||
|
|<a href="#completions.bins">bins(query, ctx, fields) -> entries (table), prefix (string)</a>|Returns binary/executale completion candidates based on the provided query.|
|
||||||
|
|<a href="#completions.files">files(query, ctx, fields) -> entries (table), prefix (string)</a>|Returns file completion candidates based on the provided query.|
|
||||||
|
|
||||||
|
## Functions
|
||||||
|
<hr><div id='completions.call'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.completions.call(name, query, ctx, fields) -> completionGroups (table), prefix (string)
|
||||||
|
<a href="#completions.call" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
Calls a completer function. This is mainly used to call
|
Calls a completer function. This is mainly used to call
|
||||||
a command completer, which will have a `name` in the form
|
a command completer, which will have a `name` in the form
|
||||||
of `command.name`, example: `command.git`.
|
of `command.name`, example: `command.git`.
|
||||||
You can check `doc completions` for info on the `completionGroups` return value.
|
You can check `doc completions` for info on the `completionGroups` return value.
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='completions.handler'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.completions.handler(line, pos)
|
||||||
|
<a href="#completions.handler" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### hilbish.completions.handler(line, pos)
|
|
||||||
The handler function is the callback for tab completion in Hilbish.
|
The handler function is the callback for tab completion in Hilbish.
|
||||||
You can check the completions doc for more info.
|
You can check the completions doc for more info.
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='completions.bins'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.completions.bins(query, ctx, fields) -> entries (table), prefix (string)
|
||||||
|
<a href="#completions.bins" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### hilbish.completions.bins(query, ctx, fields) -> entries (table), prefix (string)
|
|
||||||
Returns binary/executale completion candidates based on the provided query.
|
Returns binary/executale completion candidates based on the provided query.
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='completions.files'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.completions.files(query, ctx, fields) -> entries (table), prefix (string)
|
||||||
|
<a href="#completions.files" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### hilbish.completions.files(query, ctx, fields) -> entries (table), prefix (string)
|
|
||||||
Returns file completion candidates based on the provided query.
|
Returns file completion candidates based on the provided query.
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -12,23 +12,63 @@ The hilbish.editor interface provides functions to
|
||||||
directly interact with the line editor in use.
|
directly interact with the line editor in use.
|
||||||
|
|
||||||
## Functions
|
## Functions
|
||||||
### hilbish.editor.getLine() -> string
|
|||
|
||||||
|
|----|----|
|
||||||
|
|<a href="#editor.getLine">getLine() -> string</a>|Returns the current input line.|
|
||||||
|
|<a href="#editor.getVimRegister">getVimRegister(register) -> string</a>|Returns the text that is at the register.|
|
||||||
|
|<a href="#editor.insert">insert(text)</a>|Inserts text into the line.|
|
||||||
|
|<a href="#editor.setVimRegister">setVimRegister(register, text)</a>|Sets the vim register at `register` to hold the passed text.|
|
||||||
|
|
||||||
|
## Functions
|
||||||
|
<hr><div id='editor.getLine'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.editor.getLine() -> string
|
||||||
|
<a href="#editor.getLine" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
Returns the current input line.
|
Returns the current input line.
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='editor.getVimRegister'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.editor.getVimRegister(register) -> string
|
||||||
|
<a href="#editor.getVimRegister" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### hilbish.editor.getVimRegister(register) -> string
|
|
||||||
Returns the text that is at the register.
|
Returns the text that is at the register.
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='editor.insert'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.editor.insert(text)
|
||||||
|
<a href="#editor.insert" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### hilbish.editor.insert(text)
|
|
||||||
Inserts text into the line.
|
Inserts text into the line.
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='editor.setVimRegister'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.editor.setVimRegister(register, text)
|
||||||
|
<a href="#editor.setVimRegister" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### hilbish.editor.setVimRegister(register, text)
|
|
||||||
Sets the vim register at `register` to hold the passed text.
|
Sets the vim register at `register` to hold the passed text.
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -13,28 +13,77 @@ This includes the ability to override functions to change the main
|
||||||
method of saving history.
|
method of saving history.
|
||||||
|
|
||||||
## Functions
|
## Functions
|
||||||
### hilbish.history.add(cmd)
|
|||
|
||||||
|
|----|----|
|
||||||
|
|<a href="#history.add">add(cmd)</a>|Adds a command to the history.|
|
||||||
|
|<a href="#history.all">all() -> table</a>|Retrieves all history.|
|
||||||
|
|<a href="#history.clear">clear()</a>|Deletes all commands from the history.|
|
||||||
|
|<a href="#history.get">get(idx)</a>|Retrieves a command from the history based on the `idx`.|
|
||||||
|
|<a href="#history.size">size() -> number</a>|Returns the amount of commands in the history.|
|
||||||
|
|
||||||
|
## Functions
|
||||||
|
<hr><div id='history.add'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.history.add(cmd)
|
||||||
|
<a href="#history.add" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
Adds a command to the history.
|
Adds a command to the history.
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='history.all'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.history.all() -> table
|
||||||
|
<a href="#history.all" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### hilbish.history.all() -> table
|
|
||||||
Retrieves all history.
|
Retrieves all history.
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='history.clear'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.history.clear()
|
||||||
|
<a href="#history.clear" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### hilbish.history.clear()
|
|
||||||
Deletes all commands from the history.
|
Deletes all commands from the history.
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='history.get'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.history.get(idx)
|
||||||
|
<a href="#history.get" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### hilbish.history.get(idx)
|
|
||||||
Retrieves a command from the history based on the `idx`.
|
Retrieves a command from the history based on the `idx`.
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='history.size'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.history.size() -> number
|
||||||
|
<a href="#history.size" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### hilbish.history.size() -> number
|
|
||||||
Returns the amount of commands in the history.
|
Returns the amount of commands in the history.
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -15,42 +15,96 @@ Jobs are the name of background tasks/commands. A job can be started via
|
||||||
interactive usage or with the functions defined below for use in external runners.
|
interactive usage or with the functions defined below for use in external runners.
|
||||||
|
|
||||||
## Functions
|
## Functions
|
||||||
### hilbish.jobs.add(cmdstr, args, execPath)
|
|||
|
||||||
|
|----|----|
|
||||||
|
|<a href="#jobs.add">add(cmdstr, args, execPath)</a>|Adds a new job to the job table. Note that this does not immediately run it.|
|
||||||
|
|<a href="#jobs.all">all() -> table<@Job></a>|Returns a table of all job objects.|
|
||||||
|
|<a href="#jobs.disown">disown(id)</a>|Disowns a job. This deletes it from the job table.|
|
||||||
|
|<a href="#jobs.get">get(id) -> @Job</a>|Get a job object via its ID.|
|
||||||
|
|<a href="#jobs.last">last() -> @Job</a>|Returns the last added job from the table.|
|
||||||
|
|
||||||
|
## Functions
|
||||||
|
<hr><div id='jobs.add'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.jobs.add(cmdstr, args, execPath)
|
||||||
|
<a href="#jobs.add" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
Adds a new job to the job table. Note that this does not immediately run it.
|
Adds a new job to the job table. Note that this does not immediately run it.
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='jobs.all'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.jobs.all() -> table\<<a href="/Hilbish/docs/api/hilbish/hilbish.jobs/#job" style="text-decoration: none;" id="lol">Job</a>>
|
||||||
|
<a href="#jobs.all" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### hilbish.jobs.all() -> table\<<a href="/Hilbish/docs/api/hilbish/hilbish.jobs/#job" style="text-decoration: none;" id="lol">Job</a>>
|
|
||||||
Returns a table of all job objects.
|
Returns a table of all job objects.
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='jobs.disown'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.jobs.disown(id)
|
||||||
|
<a href="#jobs.disown" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### hilbish.jobs.disown(id)
|
|
||||||
Disowns a job. This deletes it from the job table.
|
Disowns a job. This deletes it from the job table.
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='jobs.get'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.jobs.get(id) -> <a href="/Hilbish/docs/api/hilbish/hilbish.jobs/#job" style="text-decoration: none;" id="lol">Job</a>
|
||||||
|
<a href="#jobs.get" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### hilbish.jobs.get(id) -> <a href="/Hilbish/docs/api/hilbish/hilbish.jobs/#job" style="text-decoration: none;" id="lol">Job</a>
|
|
||||||
Get a job object via its ID.
|
Get a job object via its ID.
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='jobs.last'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.jobs.last() -> <a href="/Hilbish/docs/api/hilbish/hilbish.jobs/#job" style="text-decoration: none;" id="lol">Job</a>
|
||||||
|
<a href="#jobs.last" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### hilbish.jobs.last() -> <a href="/Hilbish/docs/api/hilbish/hilbish.jobs/#job" style="text-decoration: none;" id="lol">Job</a>
|
|
||||||
Returns the last added job from the table.
|
Returns the last added job from the table.
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
## Types
|
## Types
|
||||||
|
<hr>
|
||||||
|
|
||||||
## Job
|
## Job
|
||||||
The Job type describes a Hilbish job.
|
The Job type describes a Hilbish job.
|
||||||
### Properties
|
## Object properties
|
||||||
- `cmd`: The user entered command string for the job.
|
|||
|
||||||
- `running`: Whether the job is running or not.
|
|----|----|
|
||||||
- `id`: The ID of the job in the job table
|
|cmd|The user entered command string for the job.|
|
||||||
- `pid`: The Process ID
|
|running|Whether the job is running or not.|
|
||||||
- `exitCode`: The last exit code of the job.
|
|id|The ID of the job in the job table|
|
||||||
- `stdout`: The standard output of the job. This just means the normal logs of the process.
|
|pid|The Process ID|
|
||||||
- `stderr`: The standard error stream of the process. This (usually) includes error messages of the job.
|
|exitCode|The last exit code of the job.|
|
||||||
|
|stdout|The standard output of the job. This just means the normal logs of the process.|
|
||||||
|
|stderr|The standard error stream of the process. This (usually) includes error messages of the job.|
|
||||||
|
|
||||||
|
|
||||||
### Methods
|
### Methods
|
||||||
#### background()
|
#### background()
|
||||||
|
|
|
@ -12,8 +12,10 @@ The `os` interface provides simple text information properties about
|
||||||
the current OS on the systen. This mainly includes the name and
|
the current OS on the systen. This mainly includes the name and
|
||||||
version.
|
version.
|
||||||
|
|
||||||
## Interface fields
|
## Static module fields
|
||||||
- `family`: Family name of the current OS
|
|||
|
||||||
- `name`: Pretty name of the current OS
|
|----|----|
|
||||||
- `version`: Version of the current OS
|
|family|Family name of the current OS|
|
||||||
|
|name|Pretty name of the current OS|
|
||||||
|
|version|Version of the current OS|
|
||||||
|
|
||||||
|
|
|
@ -15,23 +15,54 @@ language or script of their choosing. A good example is using it to
|
||||||
write command in Fennel.
|
write command in Fennel.
|
||||||
|
|
||||||
## Functions
|
## Functions
|
||||||
### hilbish.runner.setMode(cb)
|
|||
|
||||||
|
|----|----|
|
||||||
|
|<a href="#runner.setMode">setMode(cb)</a>|This is the same as the `hilbish.runnerMode` function. It takes a callback,|
|
||||||
|
|<a href="#runner.lua">lua(cmd)</a>|Evaluates `cmd` as Lua input. This is the same as using `dofile`|
|
||||||
|
|<a href="#runner.sh">sh(cmd)</a>|Runs a command in Hilbish's shell script interpreter.|
|
||||||
|
|
||||||
|
## Functions
|
||||||
|
<hr><div id='runner.setMode'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.runner.setMode(cb)
|
||||||
|
<a href="#runner.setMode" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
This is the same as the `hilbish.runnerMode` function. It takes a callback,
|
This is the same as the `hilbish.runnerMode` function. It takes a callback,
|
||||||
which will be used to execute all interactive input.
|
which will be used to execute all interactive input.
|
||||||
In normal cases, neither callbacks should be overrided by the user,
|
In normal cases, neither callbacks should be overrided by the user,
|
||||||
as the higher level functions listed below this will handle it.
|
as the higher level functions listed below this will handle it.
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='runner.lua'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.runner.lua(cmd)
|
||||||
|
<a href="#runner.lua" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### hilbish.runner.lua(cmd)
|
|
||||||
Evaluates `cmd` as Lua input. This is the same as using `dofile`
|
Evaluates `cmd` as Lua input. This is the same as using `dofile`
|
||||||
or `load`, but is appropriated for the runner interface.
|
or `load`, but is appropriated for the runner interface.
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='runner.sh'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.runner.sh(cmd)
|
||||||
|
<a href="#runner.sh" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### hilbish.runner.sh(cmd)
|
|
||||||
Runs a command in Hilbish's shell script interpreter.
|
Runs a command in Hilbish's shell script interpreter.
|
||||||
This is the equivalent of using `source`.
|
This is the equivalent of using `source`.
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -30,29 +30,58 @@ t:start()
|
||||||
print(t.running) // true
|
print(t.running) // true
|
||||||
```
|
```
|
||||||
|
|
||||||
## Interface fields
|
## Functions
|
||||||
- `INTERVAL`: Constant for an interval timer type
|
|||
|
||||||
- `TIMEOUT`: Constant for a timeout timer type
|
|----|----|
|
||||||
|
|<a href="#timers.create">create(type, time, callback) -> @Timer</a>|Creates a timer that runs based on the specified `time` in milliseconds.|
|
||||||
|
|<a href="#timers.get">get(id) -> @Timer</a>|Retrieves a timer via its ID.|
|
||||||
|
|
||||||
|
## Static module fields
|
||||||
|
|||
|
||||||
|
|----|----|
|
||||||
|
|INTERVAL|Constant for an interval timer type|
|
||||||
|
|TIMEOUT|Constant for a timeout timer type|
|
||||||
|
|
||||||
## Functions
|
## Functions
|
||||||
### hilbish.timers.create(type, time, callback) -> <a href="/Hilbish/docs/api/hilbish/hilbish.timers/#timer" style="text-decoration: none;" id="lol">Timer</a>
|
<hr><div id='timers.create'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.timers.create(type, time, callback) -> <a href="/Hilbish/docs/api/hilbish/hilbish.timers/#timer" style="text-decoration: none;" id="lol">Timer</a>
|
||||||
|
<a href="#timers.create" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
Creates a timer that runs based on the specified `time` in milliseconds.
|
Creates a timer that runs based on the specified `time` in milliseconds.
|
||||||
The `type` can either be `hilbish.timers.INTERVAL` or `hilbish.timers.TIMEOUT`
|
The `type` can either be `hilbish.timers.INTERVAL` or `hilbish.timers.TIMEOUT`
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='timers.get'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
hilbish.timers.get(id) -> <a href="/Hilbish/docs/api/hilbish/hilbish.timers/#timer" style="text-decoration: none;" id="lol">Timer</a>
|
||||||
|
<a href="#timers.get" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### hilbish.timers.get(id) -> <a href="/Hilbish/docs/api/hilbish/hilbish.timers/#timer" style="text-decoration: none;" id="lol">Timer</a>
|
|
||||||
Retrieves a timer via its ID.
|
Retrieves a timer via its ID.
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
## Types
|
## Types
|
||||||
|
<hr>
|
||||||
|
|
||||||
## Timer
|
## Timer
|
||||||
The Job type describes a Hilbish timer.
|
The Job type describes a Hilbish timer.
|
||||||
### Properties
|
## Object properties
|
||||||
- `type`: What type of timer it is
|
|||
|
||||||
- `running`: If the timer is running
|
|----|----|
|
||||||
- `duration`: The duration in milliseconds that the timer will run
|
|type|What type of timer it is|
|
||||||
|
|running|If the timer is running|
|
||||||
|
|duration|The duration in milliseconds that the timer will run|
|
||||||
|
|
||||||
|
|
||||||
### Methods
|
### Methods
|
||||||
#### start()
|
#### start()
|
||||||
|
|
|
@ -12,7 +12,9 @@ This interface just contains properties to know about certain user directories.
|
||||||
It is equivalent to XDG on Linux and gets the user's preferred directories
|
It is equivalent to XDG on Linux and gets the user's preferred directories
|
||||||
for configs and data.
|
for configs and data.
|
||||||
|
|
||||||
## Interface fields
|
## Static module fields
|
||||||
- `config`: The user's config directory
|
|||
|
||||||
- `data`: The user's directory for program data
|
|----|----|
|
||||||
|
|config|The user's config directory|
|
||||||
|
|data|The user's directory for program data|
|
||||||
|
|
||||||
|
|
|
@ -11,24 +11,64 @@ menu:
|
||||||
The terminal library is a simple and lower level library for certain terminal interactions.
|
The terminal library is a simple and lower level library for certain terminal interactions.
|
||||||
|
|
||||||
## Functions
|
## Functions
|
||||||
### terminal.restoreState()
|
|||
|
||||||
|
|----|----|
|
||||||
|
|<a href="#restoreState">restoreState()</a>|Restores the last saved state of the terminal|
|
||||||
|
|<a href="#saveState">saveState()</a>|Saves the current state of the terminal|
|
||||||
|
|<a href="#setRaw">setRaw()</a>|Puts the terminal in raw mode|
|
||||||
|
|<a href="#size">size()</a>|Gets the dimensions of the terminal. Returns a table with `width` and `height`|
|
||||||
|
|
||||||
|
## Functions
|
||||||
|
<hr><div id='restoreState'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
terminal.restoreState()
|
||||||
|
<a href="#restoreState" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
Restores the last saved state of the terminal
|
Restores the last saved state of the terminal
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='saveState'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
terminal.saveState()
|
||||||
|
<a href="#saveState" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### terminal.saveState()
|
|
||||||
Saves the current state of the terminal
|
Saves the current state of the terminal
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='setRaw'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
terminal.setRaw()
|
||||||
|
<a href="#setRaw" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### terminal.setRaw()
|
|
||||||
Puts the terminal in raw mode
|
Puts the terminal in raw mode
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr><div id='size'>
|
||||||
|
<h4 class='heading'>
|
||||||
|
terminal.size()
|
||||||
|
<a href="#size" class='heading-link'>
|
||||||
|
<i class="fas fa-paperclip"></i>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
### terminal.size()
|
|
||||||
Gets the dimensions of the terminal. Returns a table with `width` and `height`
|
Gets the dimensions of the terminal. Returns a table with `width` and `height`
|
||||||
Note: this is not the size in relation to the dimensions of the display
|
Note: this is not the size in relation to the dimensions of the display
|
||||||
#### Parameters
|
#### Parameters
|
||||||
This function has no parameters.
|
This function has no parameters.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
local bait = {}
|
local bait = {}
|
||||||
|
|
||||||
--- Catches a hook with `name`. Runs the `cb` when it is thrown
|
--- Catches a hook with `name`. Runs the `cb` when it is thrown
|
||||||
--- @param name string
|
|
||||||
--- @param cb function
|
|
||||||
function bait.catch(name, cb) end
|
function bait.catch(name, cb) end
|
||||||
|
|
||||||
--- Same as catch, but only runs the `cb` once and then removes the hook
|
--- Same as catch, but only runs the `cb` once and then removes the hook
|
||||||
|
|
1
go.mod
1
go.mod
|
@ -4,6 +4,7 @@ go 1.17
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/arnodel/golua v0.0.0-20220221163911-dfcf252b6f86
|
github.com/arnodel/golua v0.0.0-20220221163911-dfcf252b6f86
|
||||||
|
github.com/atsushinee/go-markdown-generator v0.0.0-20191121114853-83f9e1f68504
|
||||||
github.com/blackfireio/osinfo v1.0.3
|
github.com/blackfireio/osinfo v1.0.3
|
||||||
github.com/chuckpreslar/emission v0.0.0-20170206194824-a7ddd980baf9
|
github.com/chuckpreslar/emission v0.0.0-20170206194824-a7ddd980baf9
|
||||||
github.com/maxlandon/readline v0.1.0-beta.0.20211027085530-2b76cabb8036
|
github.com/maxlandon/readline v0.1.0-beta.0.20211027085530-2b76cabb8036
|
||||||
|
|
2
go.sum
2
go.sum
|
@ -16,6 +16,8 @@ github.com/arnodel/edit v0.0.0-20220202110212-dfc8d7a13890/go.mod h1:AcpttpuZBaL
|
||||||
github.com/arnodel/strftime v0.1.6 h1:0hc0pUvk8KhEMXE+htyaOUV42zNcf/csIbjzEFCJqsw=
|
github.com/arnodel/strftime v0.1.6 h1:0hc0pUvk8KhEMXE+htyaOUV42zNcf/csIbjzEFCJqsw=
|
||||||
github.com/arnodel/strftime v0.1.6/go.mod h1:5NbK5XqYK8QpRZpqKNt4OlxLtIB8cotkLk4KTKzJfWs=
|
github.com/arnodel/strftime v0.1.6/go.mod h1:5NbK5XqYK8QpRZpqKNt4OlxLtIB8cotkLk4KTKzJfWs=
|
||||||
github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
|
github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
|
||||||
|
github.com/atsushinee/go-markdown-generator v0.0.0-20191121114853-83f9e1f68504 h1:R1/AOzdMbopSliUTTEHvHbyNmnZ3YxY5GvdhTkpPsSY=
|
||||||
|
github.com/atsushinee/go-markdown-generator v0.0.0-20191121114853-83f9e1f68504/go.mod h1:kHBCvAXJIatTX1pw6tLiOspjGc3MhUDRlog9yrCUS+k=
|
||||||
github.com/blackfireio/osinfo v1.0.3 h1:Yk2t2GTPjBcESv6nDSWZKO87bGMQgO+Hi9OoXPpxX8c=
|
github.com/blackfireio/osinfo v1.0.3 h1:Yk2t2GTPjBcESv6nDSWZKO87bGMQgO+Hi9OoXPpxX8c=
|
||||||
github.com/blackfireio/osinfo v1.0.3/go.mod h1:Pd987poVNmd5Wsx6PRPw4+w7kLlf9iJxoRKPtPAjOrA=
|
github.com/blackfireio/osinfo v1.0.3/go.mod h1:Pd987poVNmd5Wsx6PRPw4+w7kLlf9iJxoRKPtPAjOrA=
|
||||||
github.com/chuckpreslar/emission v0.0.0-20170206194824-a7ddd980baf9 h1:xz6Nv3zcwO2Lila35hcb0QloCQsc38Al13RNEzWRpX4=
|
github.com/chuckpreslar/emission v0.0.0-20170206194824-a7ddd980baf9 h1:xz6Nv3zcwO2Lila35hcb0QloCQsc38Al13RNEzWRpX4=
|
||||||
|
|
|
@ -12,7 +12,7 @@ You can act on events via callback functions.
|
||||||
|
|
||||||
Examples of this are in the Hilbish default config!
|
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)
|
bait.catch('command.exit', function(code)
|
||||||
running = false
|
running = false
|
||||||
doPrompt(code ~= 0)
|
doPrompt(code ~= 0)
|
||||||
|
|
|
@ -22,7 +22,7 @@ The `sinks` parameter is a table with 3 keys: `in`, `out`,
|
||||||
and `err`. The values of these is a @Sink.
|
and `err`. The values of these is a @Sink.
|
||||||
|
|
||||||
- `in` is the standard input. You can read from this sink
|
- `in` is the standard input. You can read from this sink
|
||||||
to get user input. (**This is currently unimplemented.**)
|
to get user input.
|
||||||
- `out` is standard output. This is usually where text meant for
|
- `out` is standard output. This is usually where text meant for
|
||||||
output should go.
|
output should go.
|
||||||
- `err` is standard error. This sink is for writing errors, as the
|
- `err` is standard error. This sink is for writing errors, as the
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/* Background */ .bg { background-color: #ffffff; }
|
/* Background */ .bg { background-color: #edfdff; }
|
||||||
/* PreWrapper */ .chroma { background-color: #ffffff; }
|
/* PreWrapper */ .chroma { background-color: #edfdff; }
|
||||||
/* Other */ .chroma .x { }
|
/* Other */ .chroma .x { }
|
||||||
/* Error */ .chroma .err { color: #a61717; background-color: #e3d2d2 }
|
/* Error */ .chroma .err { color: #a61717; background-color: #e3d2d2 }
|
||||||
/* CodeLine */ .chroma .cl { }
|
/* CodeLine */ .chroma .cl { }
|
||||||
/* LineTableTD */ .chroma .lntd { vertical-align: top; padding: 0; margin: 0; border: 0; }
|
/* LineTableTD */ .chroma .lntd { vertical-align: top; padding: 0; margin: 0; border: 0; }
|
||||||
/* LineTable */ .chroma .lntable { border-spacing: 0; padding: 0; margin: 0; border: 0; }
|
/* LineTable */ .chroma .lntable { border-spacing: 0; padding: 0; margin: 0; border: 0; }
|
||||||
/* LineHighlight */ .chroma .hl { background-color: #ffffcc }
|
/* LineHighlight */ .chroma .hl { background-color: #edfdff }
|
||||||
/* LineNumbersTable */ .chroma .lnt { white-space: pre; user-select: none; margin-right: 0.4em; padding: 0 0.4em 0 0.4em;color: #7f7f7f }
|
/* LineNumbersTable */ .chroma .lnt { white-space: pre; user-select: none; margin-right: 0.4em; padding: 0 0.4em 0 0.4em;color: #7f7f7f }
|
||||||
/* LineNumbers */ .chroma .ln { white-space: pre; user-select: none; margin-right: 0.4em; padding: 0 0.4em 0 0.4em;color: #7f7f7f }
|
/* LineNumbers */ .chroma .ln { white-space: pre; user-select: none; margin-right: 0.4em; padding: 0 0.4em 0 0.4em;color: #7f7f7f }
|
||||||
/* Line */ .chroma .line { display: flex; }
|
/* Line */ .chroma .line { display: flex; }
|
||||||
|
|
|
@ -37,5 +37,38 @@
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
transition: all .1s ease-in;
|
transition: all .1s ease-in;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@keyframes highlight {
|
||||||
|
0% {
|
||||||
|
background: none
|
||||||
|
}
|
||||||
|
50% {
|
||||||
|
background: #fff2cf;
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
background: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
div:target {
|
||||||
|
animation: highlight 1.2s;
|
||||||
|
animation-timing-function: cubic-bezier(1,-0.02,.45,.89);
|
||||||
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
border-width: 1px;
|
||||||
|
border-style: solid;
|
||||||
|
border-color: #565c64;;
|
||||||
|
border-collapse: collapse;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
table td {
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
table tr {
|
||||||
|
border-width: 1px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
Loading…
Reference in New Issue