mirror of https://github.com/Hilbis/Hilbish
Compare commits
No commits in common. "24afb6e78168340fcf99ad294e3126db16aab407" and "7074a397991197877ec90f55b7feb827eac64ba3" have entirely different histories.
24afb6e781
...
7074a39799
|
@ -1,12 +1,5 @@
|
||||||
# 🎀 Changelog
|
# 🎀 Changelog
|
||||||
|
|
||||||
## Unreleased
|
|
||||||
### Fixed
|
|
||||||
- Heredocs having issues
|
|
||||||
|
|
||||||
### Added
|
|
||||||
- Adding `\` at the end of input will add a newline and prompt for more input.
|
|
||||||
|
|
||||||
## [2.3.2] - 2024-07-30
|
## [2.3.2] - 2024-07-30
|
||||||
### Fixed
|
### Fixed
|
||||||
- Command path searching due to 2.3 changes to the shell interpreter
|
- Command path searching due to 2.3 changes to the shell interpreter
|
||||||
|
|
|
@ -33,6 +33,19 @@ needs to run interactive input. For more detail, see the [API documentation](../
|
||||||
The `hilbish.runner` interface is an alternative to using `hilbish.runnerMode`
|
The `hilbish.runner` interface is an alternative to using `hilbish.runnerMode`
|
||||||
and also provides the shell script and Lua runner functions that Hilbish itself uses.
|
and also provides the shell script and Lua runner functions that Hilbish itself uses.
|
||||||
|
|
||||||
|
A runner function is expected to return a table with the following values:
|
||||||
|
- `exitCode` (number): Exit code of the command
|
||||||
|
- `input` (string): The text input of the user. This is used by Hilbish to append extra input, in case
|
||||||
|
more is requested.
|
||||||
|
- `err` (string): A string that represents an error from the runner.
|
||||||
|
This should only be set when, for example, there is a syntax error.
|
||||||
|
It can be set to a few special values for Hilbish to throw the right
|
||||||
|
hooks and have a better looking message.
|
||||||
|
- `<command>: not-found` will throw a `command.not-found` hook
|
||||||
|
based on what `<command>` is.
|
||||||
|
- `<command>: not-executable` will throw a `command.not-executable` hook.
|
||||||
|
- `continue` (boolean): Whether Hilbish should prompt the user for no input
|
||||||
|
|
||||||
## Functions
|
## Functions
|
||||||
These are the "low level" functions for the `hilbish.runner` interface.
|
These are the "low level" functions for the `hilbish.runner` interface.
|
||||||
|
|
||||||
|
|
6
exec.go
6
exec.go
|
@ -138,15 +138,15 @@ func runInput(input string, priv bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if cont {
|
if cont {
|
||||||
input, err = continuePrompt(input, newline)
|
input, err = reprompt(input, newline)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
goto rerun
|
goto rerun
|
||||||
} else if err == io.EOF {
|
} else if err == io.EOF {
|
||||||
lr.SetPrompt(fmtPrompt(prompt))
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil && err != io.EOF {
|
if err != nil {
|
||||||
if exErr, ok := isExecError(err); ok {
|
if exErr, ok := isExecError(err); ok {
|
||||||
hooks.Emit("command." + exErr.typ, exErr.cmd)
|
hooks.Emit("command." + exErr.typ, exErr.cmd)
|
||||||
} else {
|
} else {
|
||||||
|
|
9
main.go
9
main.go
|
@ -258,12 +258,9 @@ func continuePrompt(prev string, newline bool) (string, error) {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
if newline {
|
if newline || strings.HasSuffix(cont, "\\") {
|
||||||
cont = "\n" + cont
|
// a newline will get trimmed when this input is passed on, so we add 2
|
||||||
}
|
cont = cont + "\n\n"
|
||||||
|
|
||||||
if strings.HasSuffix(cont, "\\") {
|
|
||||||
cont = strings.TrimSuffix(cont, "\\") + "\n"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return prev + cont, nil
|
return prev + cont, nil
|
||||||
|
|
|
@ -21,18 +21,16 @@ A runner is passed the input and has to return a table with these values.
|
||||||
All are not required, only the useful ones the runner needs to return.
|
All are not required, only the useful ones the runner needs to return.
|
||||||
(So if there isn't an error, just omit `err`.)
|
(So if there isn't an error, just omit `err`.)
|
||||||
|
|
||||||
- `exitCode` (number): Exit code of the command
|
- `exitCode` (number): A numerical code to indicate the exit result.
|
||||||
- `input` (string): The text input of the user. This is used by Hilbish to append extra input, in case
|
- `input` (string): The user input. This will be used to add
|
||||||
more is requested.
|
to the history.
|
||||||
- `err` (string): A string that represents an error from the runner.
|
- `err` (string): A string to indicate an interal error for the runner.
|
||||||
This should only be set when, for example, there is a syntax error.
|
It can be set to a few special values for Hilbish to throw the right hooks and have a better looking message:
|
||||||
It can be set to a few special values for Hilbish to throw the right
|
|
||||||
hooks and have a better looking message.
|
`[command]: not-found` will throw a command.not-found hook based on what `[command]` is.
|
||||||
- `<command>: not-found` will throw a `command.not-found` hook
|
|
||||||
based on what `<command>` is.
|
`[command]: not-executable` will throw a command.not-executable hook.
|
||||||
- `<command>: not-executable` will throw a `command.not-executable` hook.
|
- `continue` (boolean): Whether to prompt the user for more input.
|
||||||
- `continue` (boolean): Whether Hilbish should prompt the user for no input
|
|
||||||
- `newline` (boolean): Whether a newline should be added at the end of `input`.
|
|
||||||
|
|
||||||
Here is a simple example of a fennel runner. It falls back to
|
Here is a simple example of a fennel runner. It falls back to
|
||||||
shell script if fennel eval has an error.
|
shell script if fennel eval has an error.
|
||||||
|
|
Loading…
Reference in New Issue