mirror of https://github.com/Hilbis/Hilbish
Compare commits
No commits in common. "97188e73a515fa43d36b0bde6c96f7d27438751b" and "5ea23d58d1fd141d39c46f253be1b5cc361923f5" have entirely different histories.
97188e73a5
...
5ea23d58d1
|
@ -41,6 +41,6 @@ jobs:
|
|||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
goos: ${{ matrix.goos }}
|
||||
goarch: ${{ matrix.goarch }}
|
||||
ldflags: '-s -w'
|
||||
build_command: task
|
||||
binary_name: hilbish
|
||||
extra_files: LICENSE README.md CHANGELOG.md .hilbishrc.lua nature libs docs emmyLuaDocs
|
||||
|
|
|
@ -92,9 +92,8 @@ func (a *aliasModule) Loader(rtm *rt.Runtime) *rt.Table {
|
|||
func _hlalias() {}
|
||||
|
||||
// #interface aliases
|
||||
// list() -> aliases (table)
|
||||
// Get a table of all aliases, with string keys as the alias and the value as the command.
|
||||
// @returns table<string, string>
|
||||
// list()
|
||||
// Get a table of all aliases.
|
||||
func (a *aliasModule) luaList(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
||||
aliasesList := rt.NewTable()
|
||||
for k, v := range a.All() {
|
||||
|
@ -122,10 +121,9 @@ func (a *aliasModule) luaDelete(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
|||
}
|
||||
|
||||
// #interface aliases
|
||||
// resolve(alias) -> command (string)
|
||||
// resolve(alias)
|
||||
// Tries to resolve an alias to its command.
|
||||
// --- @param alias string
|
||||
// --- @returns string
|
||||
func (a *aliasModule) luaResolve(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
||||
if err := c.Check1Arg(); err != nil {
|
||||
return nil, err
|
||||
|
|
16
api.go
16
api.go
|
@ -184,13 +184,11 @@ func unsetVimMode() {
|
|||
util.SetField(l, hshMod, "vimMode", rt.NilValue)
|
||||
}
|
||||
|
||||
// run(cmd, returnOut) -> exitCode (number), stdout (string), stderr (string)
|
||||
// run(cmd, returnOut) -> exitCode, stdout, stderr
|
||||
// Runs `cmd` in Hilbish's sh interpreter.
|
||||
// If returnOut is true, the outputs of `cmd` will be returned as the 2nd and
|
||||
// 3rd values instead of being outputted to the terminal.
|
||||
// --- @param cmd string
|
||||
// --- @param returnOut boolean
|
||||
// --- @returns number, string, string
|
||||
func hlrun(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
||||
if err := c.Check1Arg(); err != nil {
|
||||
return nil, err
|
||||
|
@ -240,11 +238,11 @@ func hlcwd(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
|||
}
|
||||
|
||||
|
||||
// read(prompt) -> input (string)
|
||||
// read(prompt) -> input
|
||||
// Read input from the user, using Hilbish's line editor/input reader.
|
||||
// This is a separate instance from the one Hilbish actually uses.
|
||||
// Returns `input`, will be nil if ctrl + d is pressed, or an error occurs (which shouldn't happen)
|
||||
// --- @param prompt? string
|
||||
// --- @param prompt string|nil
|
||||
// --- @returns string|nil
|
||||
func hlread(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
||||
luaprompt := c.Arg(0)
|
||||
|
@ -280,7 +278,7 @@ These will be formatted and replaced with the appropriate values.
|
|||
`%u` - Name of current user
|
||||
`%h` - Hostname of device
|
||||
--- @param str string
|
||||
--- @param typ? string Type of prompt, being left or right. Left by default.
|
||||
--- @param typ string|nil Type of prompt, being left or right. Left by default.
|
||||
*/
|
||||
func hlprompt(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
||||
err := c.Check1Arg()
|
||||
|
@ -449,7 +447,7 @@ func hlgoro(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
|||
// Returns a `timer` object (see `doc timers`).
|
||||
// --- @param cb function
|
||||
// --- @param time number
|
||||
// --- @returns table
|
||||
// --- @return table
|
||||
func hltimeout(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
||||
if err := c.CheckNArgs(2); err != nil {
|
||||
return nil, err
|
||||
|
@ -538,7 +536,7 @@ func hlprependPath(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
|||
|
||||
// which(name)
|
||||
// Checks if `name` is a valid command
|
||||
// --- @param name string
|
||||
// --- @param binName string
|
||||
func hlwhich(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
||||
if err := c.Check1Arg(); err != nil {
|
||||
return nil, err
|
||||
|
@ -623,7 +621,7 @@ func hlrunnerMode(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
|||
// as the text for the hint. This is by default a shim. To set hints,
|
||||
// override this function with your custom handler.
|
||||
// --- @param line string
|
||||
// --- @param pos number
|
||||
// --- @param pos int
|
||||
func hlhinter(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
||||
return c.Next(), nil
|
||||
}
|
||||
|
|
12
complete.go
12
complete.go
|
@ -193,8 +193,6 @@ func completionLoader(rtm *rt.Runtime) *rt.Table {
|
|||
// handler(line, pos)
|
||||
// The handler function is the callback for tab completion in Hilbish.
|
||||
// You can check the completions doc for more info.
|
||||
// --- @param line string
|
||||
// --- @param pos string
|
||||
func completionHandler(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
||||
return c.Next(), nil
|
||||
}
|
||||
|
@ -204,10 +202,6 @@ func completionHandler(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
|||
// Calls a completer function. This is mainly used to call
|
||||
// a command completer, which will have a `name` in the form
|
||||
// of `command.name`, example: `command.git`
|
||||
// --- @param name string
|
||||
// --- @param query string
|
||||
// --- @param ctx string
|
||||
// --- @param fields table
|
||||
func callLuaCompleter(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
||||
if err := c.CheckNArgs(4); err != nil {
|
||||
return nil, err
|
||||
|
@ -250,9 +244,6 @@ func callLuaCompleter(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
|||
// #interface completions
|
||||
// files(query, ctx, fields)
|
||||
// Returns file completion candidates based on the provided query.
|
||||
// --- @param query string
|
||||
// --- @param ctx string
|
||||
// --- @param fields table
|
||||
func luaFileComplete(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
||||
query, ctx, fds, err := getCompleteParams(t, c)
|
||||
if err != nil {
|
||||
|
@ -272,9 +263,6 @@ func luaFileComplete(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
|||
// #interface completions
|
||||
// bins(query, ctx, fields)
|
||||
// Returns binary/executale completion candidates based on the provided query.
|
||||
// --- @param query string
|
||||
// --- @param ctx string
|
||||
// --- @param fields table
|
||||
func luaBinaryComplete(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
||||
query, ctx, fds, err := getCompleteParams(t, c)
|
||||
if err != nil {
|
||||
|
|
|
@ -21,8 +21,8 @@ Catches a hook with `name`. Runs the `cb` when it is thrown
|
|||
### catchOnce(name, cb)
|
||||
Same as catch, but only runs the `cb` once and then removes the hook
|
||||
|
||||
### hooks(name) -> {}
|
||||
Returns a table with hooks (callback functions) on the event with `name`.
|
||||
### hooks(name) -> {cb, cb...}
|
||||
Returns a table with hooks on the event with `name`.
|
||||
|
||||
### release(name, catcher)
|
||||
Removes the `catcher` for the event with `name`
|
||||
|
|
|
@ -31,21 +31,16 @@ filepath.Dir
|
|||
Glob all files and directories that match the pattern.
|
||||
For the rules, see Go's filepath.Glob
|
||||
|
||||
### join(...)
|
||||
### join(paths...)
|
||||
Takes paths and joins them together with the OS's
|
||||
directory separator (forward or backward slash).
|
||||
|
||||
### mkdir(name, recursive)
|
||||
Makes a directory called `name`. If `recursive` is true, it will create its parent directories.
|
||||
|
||||
### readdir(dir) -> {}
|
||||
Returns a table of files in `dir`.
|
||||
### readdir(dir)
|
||||
Returns a table of files in `dir`
|
||||
|
||||
### stat(path) -> {}
|
||||
Returns a table of info about the `path`.
|
||||
It contains the following keys:
|
||||
name (string) - Name of the path
|
||||
size (number) - Size of the path
|
||||
mode (string) - Permission mode in an octal format string (with leading 0)
|
||||
isDir (boolean) - If the path is a directory
|
||||
### stat(path)
|
||||
Returns info about `path`
|
||||
|
||||
|
|
|
@ -78,12 +78,12 @@ These will be formatted and replaced with the appropriate values.
|
|||
`%u` - Name of current user
|
||||
`%h` - Hostname of device
|
||||
|
||||
### read(prompt) -> input (string)
|
||||
### read(prompt) -> input
|
||||
Read input from the user, using Hilbish's line editor/input reader.
|
||||
This is a separate instance from the one Hilbish actually uses.
|
||||
Returns `input`, will be nil if ctrl + d is pressed, or an error occurs (which shouldn't happen)
|
||||
|
||||
### run(cmd, returnOut) -> exitCode (number), stdout (string), stderr (string)
|
||||
### run(cmd, returnOut) -> exitCode, stdout, stderr
|
||||
Runs `cmd` in Hilbish's sh interpreter.
|
||||
If returnOut is true, the outputs of `cmd` will be returned as the 2nd and
|
||||
3rd values instead of being outputted to the terminal.
|
||||
|
|
|
@ -17,10 +17,9 @@ This is an alias (ha) for the `hilbish.alias` function.
|
|||
### delete(name)
|
||||
Removes an alias.
|
||||
|
||||
### list() -> aliases (table)
|
||||
Get a table of all aliases, with string keys as the alias and the value as the command.
|
||||
@returns table<string, string>
|
||||
### list()
|
||||
Get a table of all aliases.
|
||||
|
||||
### resolve(alias) -> command (string)
|
||||
### resolve(alias)
|
||||
Tries to resolve an alias to its command.
|
||||
|
||||
|
|
|
@ -40,15 +40,15 @@ Stops the job from running.
|
|||
### add(cmdstr, args, execPath)
|
||||
Adds a new job to the job table. Note that this does not immediately run it.
|
||||
|
||||
### all() -> jobs (table<Job/Table>)
|
||||
### all()
|
||||
Returns a table of all job objects.
|
||||
|
||||
### disown(id)
|
||||
Disowns a job. This deletes it from the job table.
|
||||
|
||||
### get(id) -> job (Job/Table)
|
||||
### get(id)
|
||||
Get a job object via its ID.
|
||||
|
||||
### last() -> job (Job/Table)
|
||||
### last() -> Job
|
||||
Returns the last added job from the table.
|
||||
|
||||
|
|
|
@ -12,10 +12,6 @@ The timers interface si one to easily set timeouts and intervals
|
|||
to run functions after a certain time or repeatedly without using
|
||||
odd tricks.
|
||||
|
||||
## Interface fields
|
||||
- `INTERVAL`: Constant for an interval timer type
|
||||
- `TIMEOUT`: Constant for a timeout timer type
|
||||
|
||||
## Object properties
|
||||
- `type`: What type of timer it is
|
||||
- `running`: If the timer is running
|
||||
|
@ -30,8 +26,8 @@ Stops a timer.
|
|||
|
||||
### create(type, time, callback)
|
||||
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 interval (value of 0) or timeout (value of 1).
|
||||
|
||||
### get(id) -> timer (Timer/Table)
|
||||
### get(id)
|
||||
Retrieves a timer via its ID.
|
||||
|
||||
|
|
|
@ -45,8 +45,6 @@ func editorInsert(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
|||
// #interface editor
|
||||
// setVimRegister(register, text)
|
||||
// Sets the vim register at `register` to hold the passed text.
|
||||
// --- @param register string
|
||||
// --- @param text string
|
||||
func editorSetRegister(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
||||
if err := c.Check1Arg(); err != nil {
|
||||
return nil, err
|
||||
|
@ -70,7 +68,6 @@ func editorSetRegister(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
|||
// #interface editor
|
||||
// getVimRegister(register)
|
||||
// Returns the text that is at the register.
|
||||
// --- @param register string
|
||||
func editorGetRegister(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
||||
if err := c.Check1Arg(); err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -12,9 +12,9 @@ function bait.catch(name, cb) end
|
|||
--- @param cb function
|
||||
function bait.catchOnce(name, cb) end
|
||||
|
||||
--- Returns a table with hooks (callback functions) on the event with `name`.
|
||||
--- Returns a table with hooks on the event with `name`.
|
||||
--- @param name string
|
||||
--- @returns table<function>
|
||||
--- @returns table
|
||||
function bait.hooks(name) end
|
||||
|
||||
--- Removes the `catcher` for the event with `name`
|
||||
|
|
|
@ -16,37 +16,28 @@ function fs.cd(dir) end
|
|||
|
||||
--- Returns the directory part of `path`. For the rules, see Go's
|
||||
--- filepath.Dir
|
||||
--- @param path string
|
||||
function fs.dir(path) end
|
||||
|
||||
--- Glob all files and directories that match the pattern.
|
||||
--- For the rules, see Go's filepath.Glob
|
||||
--- @param pattern string
|
||||
function fs.glob(pattern) end
|
||||
|
||||
--- Takes paths and joins them together with the OS's
|
||||
--- directory separator (forward or backward slash).
|
||||
--- @vararg any
|
||||
function fs.join(...) end
|
||||
function fs.join(paths...) end
|
||||
|
||||
--- Makes a directory called `name`. If `recursive` is true, it will create its parent directories.
|
||||
--- @param name string
|
||||
--- @param recursive boolean
|
||||
function fs.mkdir(name, recursive) end
|
||||
|
||||
--- Returns a table of files in `dir`.
|
||||
--- Returns a table of files in `dir`
|
||||
--- @param dir string
|
||||
--- @return table
|
||||
function fs.readdir(dir) end
|
||||
|
||||
--- Returns a table of info about the `path`.
|
||||
--- It contains the following keys:
|
||||
--- name (string) - Name of the path
|
||||
--- size (number) - Size of the path
|
||||
--- mode (string) - Permission mode in an octal format string (with leading 0)
|
||||
--- isDir (boolean) - If the path is a directory
|
||||
--- Returns info about `path`
|
||||
--- @param path string
|
||||
--- @returns table
|
||||
function fs.stat(path) end
|
||||
|
||||
return fs
|
||||
|
|
|
@ -11,37 +11,27 @@ function hilbish.aliases.add(alias, cmd) end
|
|||
--- which will be used to execute all interactive input.
|
||||
--- In normal cases, neither callbacks should be overrided by the user,
|
||||
--- as the higher level functions listed below this will handle it.
|
||||
--- @param cb function
|
||||
function hilbish.runner.setMode(cb) end
|
||||
|
||||
--- Calls a completer function. This is mainly used to call
|
||||
--- a command completer, which will have a `name` in the form
|
||||
--- of `command.name`, example: `command.git`
|
||||
--- @param name string
|
||||
--- @param query string
|
||||
--- @param ctx string
|
||||
--- @param fields table
|
||||
function hilbish.completions.call(name, query, ctx, fields) end
|
||||
|
||||
--- The handler function is the callback for tab completion in Hilbish.
|
||||
--- You can check the completions doc for more info.
|
||||
--- @param line string
|
||||
--- @param pos string
|
||||
function hilbish.completions.handler(line, pos) end
|
||||
|
||||
--- Returns the current input line.
|
||||
function hilbish.editor.getLine() end
|
||||
|
||||
--- Returns the text that is at the register.
|
||||
--- @param register string
|
||||
function hilbish.editor.getVimRegister(register) end
|
||||
|
||||
--- Inserts text into the line.
|
||||
function hilbish.editor.insert(text) end
|
||||
|
||||
--- Sets the vim register at `register` to hold the passed text.
|
||||
--- @param register string
|
||||
--- @param text string
|
||||
function hilbish.editor.setVimRegister(register, text) end
|
||||
|
||||
--- Sets an alias of `cmd` to `orig`
|
||||
|
@ -86,7 +76,7 @@ function hilbish.highlighter(line) end
|
|||
--- as the text for the hint. This is by default a shim. To set hints,
|
||||
--- override this function with your custom handler.
|
||||
--- @param line string
|
||||
--- @param pos number
|
||||
--- @param pos int
|
||||
function hilbish.hinter(line, pos) end
|
||||
|
||||
--- Sets the input mode for Hilbish's line reader. Accepts either emacs or vim
|
||||
|
@ -115,13 +105,13 @@ function hilbish.prependPath(dir) end
|
|||
--- `%u` - Name of current user
|
||||
--- `%h` - Hostname of device
|
||||
--- @param str string
|
||||
--- @param typ? string Type of prompt, being left or right. Left by default.
|
||||
--- @param typ string|nil Type of prompt, being left or right. Left by default.
|
||||
function hilbish.prompt(str, typ) end
|
||||
|
||||
--- Read input from the user, using Hilbish's line editor/input reader.
|
||||
--- This is a separate instance from the one Hilbish actually uses.
|
||||
--- Returns `input`, will be nil if ctrl + d is pressed, or an error occurs (which shouldn't happen)
|
||||
--- @param prompt? string
|
||||
--- @param prompt string|nil
|
||||
--- @returns string|nil
|
||||
function hilbish.read(prompt) end
|
||||
|
||||
|
@ -129,8 +119,6 @@ function hilbish.read(prompt) end
|
|||
--- If returnOut is true, the outputs of `cmd` will be returned as the 2nd and
|
||||
--- 3rd values instead of being outputted to the terminal.
|
||||
--- @param cmd string
|
||||
--- @param returnOut boolean
|
||||
--- @returns number, string, string
|
||||
function hilbish.run(cmd, returnOut) end
|
||||
|
||||
--- Sets the execution/runner mode for interactive Hilbish. This determines whether
|
||||
|
@ -145,26 +133,20 @@ function hilbish.runnerMode(mode) end
|
|||
--- Returns a `timer` object (see `doc timers`).
|
||||
--- @param cb function
|
||||
--- @param time number
|
||||
--- @returns table
|
||||
--- @return table
|
||||
function hilbish.timeout(cb, time) end
|
||||
|
||||
--- Checks if `name` is a valid command
|
||||
--- @param name string
|
||||
--- @param binName string
|
||||
function hilbish.which(name) end
|
||||
|
||||
--- Puts a job in the background. This acts the same as initially running a job.
|
||||
function hilbish.jobs:background() end
|
||||
|
||||
--- Returns binary/executale completion candidates based on the provided query.
|
||||
--- @param query string
|
||||
--- @param ctx string
|
||||
--- @param fields table
|
||||
function hilbish.completions.bins(query, ctx, fields) end
|
||||
|
||||
--- Returns file completion candidates based on the provided query.
|
||||
--- @param query string
|
||||
--- @param ctx string
|
||||
--- @param fields table
|
||||
function hilbish.completions.files(query, ctx, fields) end
|
||||
|
||||
--- Puts a job in the foreground. This will cause it to run like it was
|
||||
|
@ -173,7 +155,6 @@ function hilbish.jobs:foreground() end
|
|||
|
||||
--- Evaluates `cmd` as Lua input. This is the same as using `dofile`
|
||||
--- or `load`, but is appropriated for the runner interface.
|
||||
--- @param cmd string
|
||||
function hilbish.runner.lua(cmd) end
|
||||
|
||||
--- Starts running the job.
|
||||
|
@ -184,7 +165,6 @@ function hilbish.jobs.stop() end
|
|||
|
||||
--- Runs a command in Hilbish's shell script interpreter.
|
||||
--- This is the equivalent of using `source`.
|
||||
--- @param cmd string
|
||||
function hilbish.runner.sh(cmd) end
|
||||
|
||||
--- Starts a timer.
|
||||
|
@ -197,36 +177,26 @@ function hilbish.timers:stop() end
|
|||
--- @param name string
|
||||
function hilbish.aliases.delete(name) end
|
||||
|
||||
--- Get a table of all aliases, with string keys as the alias and the value as the command.
|
||||
--- @returns table<string, string>
|
||||
--- Get a table of all aliases.
|
||||
function hilbish.aliases.list() end
|
||||
|
||||
--- Tries to resolve an alias to its command.
|
||||
--- @param alias string
|
||||
--- @returns string
|
||||
function hilbish.aliases.resolve(alias) end
|
||||
|
||||
--- Adds a new job to the job table. Note that this does not immediately run it.
|
||||
--- @param cmdstr string
|
||||
--- @param args table
|
||||
--- @param execPath string
|
||||
function hilbish.jobs.add(cmdstr, args, execPath) end
|
||||
|
||||
--- Returns a table of all job objects.
|
||||
--- @returns table<Job>
|
||||
function hilbish.jobs.all() end
|
||||
|
||||
--- Disowns a job. This deletes it from the job table.
|
||||
--- @param id number
|
||||
function hilbish.jobs.disown(id) end
|
||||
|
||||
--- Get a job object via its ID.
|
||||
--- @param id number
|
||||
--- @returns Job
|
||||
function hilbish.jobs.get(id) end
|
||||
|
||||
--- Returns the last added job from the table.
|
||||
--- @returns Job
|
||||
function hilbish.jobs.last() end
|
||||
|
||||
--- Adds a command to the history.
|
||||
|
@ -245,15 +215,10 @@ function hilbish.history.get(idx) end
|
|||
function hilbish.history.size() end
|
||||
|
||||
--- Creates a timer that runs based on the specified `time` in milliseconds.
|
||||
--- The `type` can either be `hilbish.timers.INTERVAL` or `hilbish.timers.TIMEOUT`
|
||||
--- @param type number
|
||||
--- @param time number
|
||||
--- @param callback function
|
||||
--- The `type` can either be interval (value of 0) or timeout (value of 1).
|
||||
function hilbish.timers.create(type, time, callback) end
|
||||
|
||||
--- Retrieves a timer via its ID.
|
||||
--- @param id number
|
||||
--- @returns Timer
|
||||
function hilbish.timers.get(id) end
|
||||
|
||||
return hilbish
|
||||
|
|
|
@ -296,10 +296,10 @@ func (b *Bait) brelease(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
|||
return c.Next(), nil
|
||||
}
|
||||
|
||||
// hooks(name) -> {}
|
||||
// Returns a table with hooks (callback functions) on the event with `name`.
|
||||
// hooks(name) -> {cb, cb...}
|
||||
// Returns a table with hooks on the event with `name`.
|
||||
// --- @param name string
|
||||
// --- @returns table<function>
|
||||
// --- @returns table
|
||||
func (b *Bait) bhooks(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
||||
if err := c.Check1Arg(); err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -93,15 +93,9 @@ func fmkdir(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
|||
return c.Next(), err
|
||||
}
|
||||
|
||||
// stat(path) -> {}
|
||||
// Returns a table of info about the `path`.
|
||||
// It contains the following keys:
|
||||
// name (string) - Name of the path
|
||||
// size (number) - Size of the path
|
||||
// mode (string) - Permission mode in an octal format string (with leading 0)
|
||||
// isDir (boolean) - If the path is a directory
|
||||
// stat(path)
|
||||
// Returns info about `path`
|
||||
// --- @param path string
|
||||
// --- @returns table
|
||||
func fstat(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
||||
if err := c.Check1Arg(); err != nil {
|
||||
return nil, err
|
||||
|
@ -125,8 +119,8 @@ func fstat(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
|||
return c.PushingNext1(t.Runtime, rt.TableValue(statTbl)), nil
|
||||
}
|
||||
|
||||
// readdir(dir) -> {}
|
||||
// Returns a table of files in `dir`.
|
||||
// readdir(dir)
|
||||
// Returns a table of files in `dir`
|
||||
// --- @param dir string
|
||||
// --- @return table
|
||||
func freaddir(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
||||
|
@ -187,7 +181,6 @@ func fbasename(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
|||
// dir(path)
|
||||
// Returns the directory part of `path`. For the rules, see Go's
|
||||
// filepath.Dir
|
||||
// --- @param path string
|
||||
func fdir(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
||||
if err := c.Check1Arg(); err != nil {
|
||||
return nil, err
|
||||
|
@ -203,7 +196,6 @@ func fdir(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
|||
// glob(pattern)
|
||||
// Glob all files and directories that match the pattern.
|
||||
// For the rules, see Go's filepath.Glob
|
||||
// --- @param pattern string
|
||||
func fglob(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
||||
if err := c.Check1Arg(); err != nil {
|
||||
return nil, err
|
||||
|
@ -227,10 +219,9 @@ func fglob(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
|||
return c.PushingNext(t.Runtime, rt.TableValue(luaMatches)), nil
|
||||
}
|
||||
|
||||
// join(...)
|
||||
// join(paths...)
|
||||
// Takes paths and joins them together with the OS's
|
||||
// directory separator (forward or backward slash).
|
||||
// --- @vararg any
|
||||
func fjoin(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
||||
strs := make([]string, len(c.Etc()))
|
||||
for i, v := range c.Etc() {
|
||||
|
|
14
job.go
14
job.go
|
@ -384,10 +384,8 @@ func jobUserData(j *job) *rt.UserData {
|
|||
}
|
||||
|
||||
// #interface jobs
|
||||
// get(id) -> job (Job/Table)
|
||||
// get(id)
|
||||
// Get a job object via its ID.
|
||||
// --- @param id number
|
||||
// --- @returns Job
|
||||
func (j *jobHandler) luaGetJob(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
||||
j.mu.RLock()
|
||||
defer j.mu.RUnlock()
|
||||
|
@ -411,9 +409,6 @@ func (j *jobHandler) luaGetJob(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
|||
// #interface jobs
|
||||
// add(cmdstr, args, execPath)
|
||||
// Adds a new job to the job table. Note that this does not immediately run it.
|
||||
// --- @param cmdstr string
|
||||
// --- @param args table
|
||||
// --- @param execPath string
|
||||
func (j *jobHandler) luaAddJob(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
||||
if err := c.CheckNArgs(3); err != nil {
|
||||
return nil, err
|
||||
|
@ -444,9 +439,8 @@ func (j *jobHandler) luaAddJob(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
|||
}
|
||||
|
||||
// #interface jobs
|
||||
// all() -> jobs (table<Job/Table>)
|
||||
// all()
|
||||
// Returns a table of all job objects.
|
||||
// --- @returns table<Job>
|
||||
func (j *jobHandler) luaAllJobs(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
||||
j.mu.RLock()
|
||||
defer j.mu.RUnlock()
|
||||
|
@ -462,7 +456,6 @@ func (j *jobHandler) luaAllJobs(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
|||
// #interface jobs
|
||||
// disown(id)
|
||||
// Disowns a job. This deletes it from the job table.
|
||||
// --- @param id number
|
||||
func (j *jobHandler) luaDisownJob(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
||||
if err := c.Check1Arg(); err != nil {
|
||||
return nil, err
|
||||
|
@ -481,9 +474,8 @@ func (j *jobHandler) luaDisownJob(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
|||
}
|
||||
|
||||
// #interface jobs
|
||||
// last() -> job (Job/Table)
|
||||
// last() -> Job
|
||||
// Returns the last added job from the table.
|
||||
// --- @returns Job
|
||||
func (j *jobHandler) luaLastJob(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
||||
j.mu.RLock()
|
||||
defer j.mu.RUnlock()
|
||||
|
|
|
@ -32,14 +32,12 @@ func runnerModeLoader(rtm *rt.Runtime) *rt.Table {
|
|||
// which will be used to execute all interactive input.
|
||||
// In normal cases, neither callbacks should be overrided by the user,
|
||||
// as the higher level functions listed below this will handle it.
|
||||
// --- @param cb function
|
||||
func _runnerMode() {}
|
||||
|
||||
// #interface runner
|
||||
// sh(cmd)
|
||||
// Runs a command in Hilbish's shell script interpreter.
|
||||
// This is the equivalent of using `source`.
|
||||
// --- @param cmd string
|
||||
func shRunner(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
||||
if err := c.Check1Arg(); err != nil {
|
||||
return nil, err
|
||||
|
@ -67,7 +65,6 @@ func shRunner(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
|||
// lua(cmd)
|
||||
// Evaluates `cmd` as Lua input. This is the same as using `dofile`
|
||||
// or `load`, but is appropriated for the runner interface.
|
||||
// --- @param cmd string
|
||||
func luaRunner(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
||||
if err := c.Check1Arg(); err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -64,10 +64,7 @@ func (th *timersModule) get(id int) *timer {
|
|||
// #interface timers
|
||||
// create(type, time, callback)
|
||||
// Creates a timer that runs based on the specified `time` in milliseconds.
|
||||
// The `type` can either be `hilbish.timers.INTERVAL` or `hilbish.timers.TIMEOUT`
|
||||
// --- @param type number
|
||||
// --- @param time number
|
||||
// --- @param callback function
|
||||
// The `type` can either be interval (value of 0) or timeout (value of 1).
|
||||
func (th *timersModule) luaCreate(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
||||
if err := c.CheckNArgs(3); err != nil {
|
||||
return nil, err
|
||||
|
@ -91,10 +88,8 @@ func (th *timersModule) luaCreate(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
|||
}
|
||||
|
||||
// #interface timers
|
||||
// get(id) -> timer (Timer/Table)
|
||||
// get(id)
|
||||
// Retrieves a timer via its ID.
|
||||
// --- @param id number
|
||||
// --- @returns Timer
|
||||
func (th *timersModule) luaGet(thr *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
||||
if err := c.Check1Arg(); err != nil {
|
||||
return nil, err
|
||||
|
@ -113,8 +108,6 @@ func (th *timersModule) luaGet(thr *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
|||
}
|
||||
|
||||
// #interface timers
|
||||
// #field INTERVAL Constant for an interval timer type
|
||||
// #field TIMEOUT Constant for a timeout timer type
|
||||
// #property type What type of timer it is
|
||||
// #property running If the timer is running
|
||||
// #property duration The duration in milliseconds that the timer will run
|
||||
|
@ -163,9 +156,6 @@ func (th *timersModule) loader(rtm *rt.Runtime) *rt.Table {
|
|||
luaTh := rt.NewTable()
|
||||
util.SetExports(rtm, luaTh, thExports)
|
||||
|
||||
util.SetField(rtm, luaTh, "INTERVAL", rt.IntValue(0))
|
||||
util.SetField(rtm, luaTh, "TIMEOUT", rt.IntValue(1))
|
||||
|
||||
return luaTh
|
||||
}
|
||||
|
||||
|
|
|
@ -5,9 +5,15 @@ weight: -1
|
|||
menu: docs
|
||||
---
|
||||
|
||||
Hilbish is a hyper-extensible shell mainly intended for interactive use.
|
||||
To enhance the interactive experience, Hilbish comes with a wide range
|
||||
of features and sane defaults, including a nice looking prompt,
|
||||
advanced completion menus and history search.
|
||||
Here lies the documentation for Hilbish, the hyper extensible Lua shell.
|
||||
Hilbish provides you with a few quality of life features and useful
|
||||
functions to ensure you can make the shell fully yours.
|
||||
|
||||
Here documents some of the features of Hilbish and the Lua API.
|
||||
These features include:
|
||||
- Completion and history search menus
|
||||
- Hinting and syntax highlighting (scripted by user)
|
||||
|
||||
# Installation
|
||||
Steps on installing Hilbish will be at the Install page in the navigation bar
|
||||
at the top. This also included getting development builds from the GitHub
|
||||
repository.
|
||||
|
|
Loading…
Reference in New Issue