Compare commits

...

7 Commits

Author SHA1 Message Date
TorchedSammy 21b093559a docs: [ci] generate new docs 2022-02-26 15:37:02 +00:00
TorchedSammy e5566f672a
chore: merge from upstream 2022-02-26 11:36:34 -04:00
TorchedSammy 715a67b882
docs: add emmylua annotations for hilbish module functions 2022-02-26 11:36:04 -04:00
TorchedSammy 18abb66ad4 docs: [ci] generate new docs 2022-02-26 15:32:36 +00:00
TorchedSammy 9d390c87cf
docs: put breaking changes under a separate heading 2022-02-26 11:32:10 -04:00
TorchedSammy e3a0195eb3
refactor!: remove hilbish.flag
not really that useful
2022-02-26 11:29:20 -04:00
TorchedSammy 06221e06cd
chore: fix hilbiline version 2022-02-26 11:25:28 -04:00
6 changed files with 55 additions and 42 deletions

View File

@ -22,19 +22,22 @@ with Lua
### Changed
- The minimal config is truly minimal now
- (Possibly) **Breaking Change:** Change default SHLVL to 0 instead of 1
- **Breaking Change:** ~/.hilbishrc.lua will no longer be run by default, it now
#### Breaking Changes
(there were a lot...)
- Change default SHLVL to 0 instead of 1
- ~/.hilbishrc.lua will no longer be run by default, it now
only uses the paths mentioned below.
- **Breaking Change:** Changed Hilbish's config path to something more suited
- Changed Hilbish's config path to something more suited
according to the OS (`$XDG_CONFIG_HOME/hilbish/init.lua` on Linux,
`~/Library/Application Support/hilbish/init.lua` on MacOs and
(`%APPDATA%/hilbish/init.lua` on Windows). Previously on Unix-like it was
`$XDG_CONFIG_HOME/hilbish/hilbishrc.lua`
- **Breaking Change:** The history path has been changed to a better suited path.
- The history path has been changed to a better suited path.
On Linux, it is `$XDG_DATA_HOME/hilbish/.hilbish-history` and for others it is
the config path.
- **Breaking Change:** `hilbish.xdg` no longer exists, use `hilbish.userDir` instead,
- `hilbish.xdg` no longer exists, use `hilbish.userDir` instead,
as it functions the same and is OS agnostic
- `hilbish.flag` has been removed
## [0.7.1] - 2021-11-22
### Fixed

38
api.go
View File

@ -14,7 +14,6 @@ import (
"hilbish/util"
"github.com/pborman/getopt"
"github.com/yuin/gopher-lua"
"mvdan.cc/sh/v3/interp"
)
@ -24,7 +23,6 @@ var exports = map[string]lua.LGFunction {
"appendPath": hlappendPath,
"cwd": hlcwd,
"exec": hlexec,
"flag": hlflag,
"multiprompt": hlmlprompt,
"prependPath": hlprependPath,
"prompt": hlprompt,
@ -86,6 +84,7 @@ The nice lil shell for {blue}Lua{reset} fanatics!
// run(cmd)
// Runs `cmd` in Hilbish's sh interpreter.
// --- @param cmd string
func hlrun(L *lua.LState) int {
var exitcode uint8
cmd := L.CheckString(1)
@ -101,23 +100,6 @@ func hlrun(L *lua.LState) int {
return 1
}
// flag(f)
// Checks if the `f` flag has been passed to Hilbish.
func hlflag(L *lua.LState) int {
flagchar := L.CheckString(1)
flag := getopt.Lookup([]rune(flagchar)[0])
if flag == nil {
L.Push(lua.LNil)
return 1
}
passed := flag.Seen()
L.Push(lua.LBool(passed))
return 1
}
// cwd()
// Returns the current directory of the shell
func hlcwd(L *lua.LState) int {
@ -140,6 +122,7 @@ func getenv(key, fallback string) string {
// 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
func hlread(L *lua.LState) int {
luaprompt := L.CheckString(1)
lualr := newLineReader(luaprompt)
@ -154,13 +137,16 @@ func hlread(L *lua.LState) int {
return 1
}
/* prompt(str)
/*
prompt(str)
Changes the shell prompt to `str`
There are a few verbs that can be used in the prompt text.
These will be formatted and replaced with the appropriate values.
`%d` - Current working directory
`%u` - Name of current user
`%h` - Hostname of device */
`%h` - Hostname of device
--- @param str string
*/
func hlprompt(L *lua.LState) int {
prompt = L.CheckString(1)
@ -169,6 +155,7 @@ func hlprompt(L *lua.LState) int {
// multiprompt(str)
// Changes the continued line prompt to `str`
// --- @param str string
func hlmlprompt(L *lua.LState) int {
multilinePrompt = L.CheckString(1)
@ -177,6 +164,8 @@ func hlmlprompt(L *lua.LState) int {
// alias(cmd, orig)
// Sets an alias of `orig` to `cmd`
// --- @param cmd string
// --- @param orig string
func hlalias(L *lua.LState) int {
alias := L.CheckString(1)
source := L.CheckString(2)
@ -188,6 +177,7 @@ func hlalias(L *lua.LState) int {
// appendPath(dir)
// Appends `dir` to $PATH
// --- @param dir string|table
func hlappendPath(L *lua.LState) int {
// check if dir is a table or a string
arg := L.Get(1)
@ -217,6 +207,7 @@ func appendPath(dir string) {
// exec(cmd)
// Replaces running hilbish with `cmd`
// --- @param cmd string
func hlexec(L *lua.LState) int {
cmd := L.CheckString(1)
cmdArgs, _ := splitInput(cmd)
@ -236,6 +227,7 @@ func hlexec(L *lua.LState) int {
// goro(fn)
// Puts `fn` in a goroutine
// --- @param fn function
func hlgoroutine(L *lua.LState) int {
fn := L.CheckFunction(1)
argnum := L.GetTop()
@ -258,6 +250,8 @@ func hlgoroutine(L *lua.LState) int {
// timeout(cb, time)
// Runs the `cb` function after `time` in milliseconds
// --- @param cb function
// --- @param time number
func hltimeout(L *lua.LState) int {
cb := L.CheckFunction(1)
ms := L.CheckInt(2)
@ -275,6 +269,8 @@ func hltimeout(L *lua.LState) int {
// interval(cb, time)
// Runs the `cb` function every `time` milliseconds
// --- @param cb function
// --- @param time number
func hlinterval(L *lua.LState) int {
intervalfunc := L.CheckFunction(1)
ms := L.CheckInt(2)

View File

@ -12,8 +12,6 @@ cwd() > Returns the current directory of the shell
exec(cmd) > Replaces running hilbish with `cmd`
flag(f) > Checks if the `f` flag has been passed to Hilbish.
goro(fn) > Puts `fn` in a goroutine
interval(cb, time) > Runs the `cb` function every `time` milliseconds

View File

@ -3,10 +3,13 @@
local hilbish = {}
--- Sets an alias of `orig` to `cmd`
function hilbish.alias() end
--- @param cmd string
--- @param orig string
function hilbish.alias(cmd, orig) end
--- Appends `dir` to $PATH
function hilbish.appendPath() end
--- @param dir string|table
function hilbish.appendPath(dir) end
--- Registers a completion handler for `scope`.
--- A `scope` is currently only expected to be `command.<cmd>`,
@ -19,19 +22,21 @@ function hilbish.complete() end
function hilbish.cwd() end
--- Replaces running hilbish with `cmd`
function hilbish.exec() end
--- Checks if the `f` flag has been passed to Hilbish.
function hilbish.flag() end
--- @param cmd string
function hilbish.exec(cmd) end
--- Puts `fn` in a goroutine
function hilbish.goroutine() end
--- @param fn function
function hilbish.goroutine(fn) end
--- Runs the `cb` function every `time` milliseconds
function hilbish.interval() end
--- @param cb function
--- @param time number
function hilbish.interval(cb, time) end
--- Changes the continued line prompt to `str`
function hilbish.mlprompt() end
--- @param str string
function hilbish.mlprompt(str) end
--- Prepends `dir` to $PATH
function hilbish.prependPath() end
@ -42,17 +47,22 @@ function hilbish.prependPath() end
--- `%d` - Current working directory
--- `%u` - Name of current user
--- `%h` - Hostname of device
function hilbish.prompt() end
--- @param str string
function hilbish.prompt(str) 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)
function hilbish.read() end
--- @param prompt string
function hilbish.read(prompt) end
--- Runs `cmd` in Hilbish's sh interpreter.
function hilbish.run() end
--- @param cmd string
function hilbish.run(cmd) end
--- Runs the `cb` function after `time` in milliseconds
function hilbish.timeout() end
--- @param cb function
--- @param time number
function hilbish.timeout(cb, time) end
return hilbish

6
go.mod
View File

@ -3,12 +3,16 @@ module hilbish
go 1.16
require (
github.com/Rosettea/Hilbiline v0.0.0-20210710124707-aa6e3ff34cb2
github.com/Rosettea/Hilbiline v0.0.0-20210624011007-8088a2d84b65
github.com/Rosettea/readline v0.0.0-20211207004608-4afb088da503
github.com/chuckpreslar/emission v0.0.0-20170206194824-a7ddd980baf9
github.com/creack/goselect v0.1.2 // indirect
github.com/creack/termios v0.0.0-20160714173321-88d0029e36a1 // indirect
github.com/kr/pty v1.1.8 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/maxlandon/readline v0.1.0-beta.0.20211027085530-2b76cabb8036
github.com/pborman/ansi v1.0.0 // indirect
github.com/pborman/getopt v1.1.0
github.com/yuin/gopher-lua v0.0.0-20210529063254-f4c35e4016d9
golang.org/x/sys v0.0.0-20220224120231-95c6836cb0e7 // indirect

2
go.sum
View File

@ -1,3 +1,5 @@
github.com/Rosettea/Hilbiline v0.0.0-20210624011007-8088a2d84b65 h1:z6alP313nLg1U/V3bKSd6849L/A2LxDSwKv4CPqqzDk=
github.com/Rosettea/Hilbiline v0.0.0-20210624011007-8088a2d84b65/go.mod h1:/FFZ4cgR6TXXYaskRUxyLIYdfG0PS4BPtWjWRQms754=
github.com/Rosettea/Hilbiline v0.0.0-20210710124707-aa6e3ff34cb2 h1:6f1umn6mkodpGf6rK9LZjr4Gut2uS+b8QLoFBFTeOE8=
github.com/Rosettea/Hilbiline v0.0.0-20210710124707-aa6e3ff34cb2/go.mod h1:0J2+sRC+d4a3swcH20sVlFvYUEXASvGTHJnVTTI4S9w=
github.com/Rosettea/readline v0.0.0-20211207004608-4afb088da503 h1:hA2kXBwY8SFH3+PT67CkoUjlMuRN08RSEtsKjwQ+of4=