Compare commits

..

No commits in common. "21b093559a6c911733b26b7e5cb81830475542d3" and "fd513b6ae307ebd9596fea1176c87ba474234c17" have entirely different histories.

6 changed files with 42 additions and 55 deletions

View File

@ -22,22 +22,19 @@ with Lua
### Changed
- The minimal config is truly minimal 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
- (Possibly) **Breaking Change:** Change default SHLVL to 0 instead of 1
- **Breaking Change:** ~/.hilbishrc.lua will no longer be run by default, it now
only uses the paths mentioned below.
- Changed Hilbish's config path to something more suited
- **Breaking Change:** 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`
- The history path has been changed to a better suited path.
- **Breaking Change:** 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.
- `hilbish.xdg` no longer exists, use `hilbish.userDir` instead,
- **Breaking Change:** `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,6 +14,7 @@ import (
"hilbish/util"
"github.com/pborman/getopt"
"github.com/yuin/gopher-lua"
"mvdan.cc/sh/v3/interp"
)
@ -23,6 +24,7 @@ var exports = map[string]lua.LGFunction {
"appendPath": hlappendPath,
"cwd": hlcwd,
"exec": hlexec,
"flag": hlflag,
"multiprompt": hlmlprompt,
"prependPath": hlprependPath,
"prompt": hlprompt,
@ -84,7 +86,6 @@ 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)
@ -100,6 +101,23 @@ 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 {
@ -122,7 +140,6 @@ 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)
@ -137,16 +154,13 @@ 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
--- @param str string
*/
`%h` - Hostname of device */
func hlprompt(L *lua.LState) int {
prompt = L.CheckString(1)
@ -155,7 +169,6 @@ 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)
@ -164,8 +177,6 @@ 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)
@ -177,7 +188,6 @@ 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)
@ -207,7 +217,6 @@ 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)
@ -227,7 +236,6 @@ 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()
@ -250,8 +258,6 @@ 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)
@ -269,8 +275,6 @@ 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,6 +12,8 @@ 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,13 +3,10 @@
local hilbish = {}
--- Sets an alias of `orig` to `cmd`
--- @param cmd string
--- @param orig string
function hilbish.alias(cmd, orig) end
function hilbish.alias() end
--- Appends `dir` to $PATH
--- @param dir string|table
function hilbish.appendPath(dir) end
function hilbish.appendPath() end
--- Registers a completion handler for `scope`.
--- A `scope` is currently only expected to be `command.<cmd>`,
@ -22,21 +19,19 @@ function hilbish.complete() end
function hilbish.cwd() end
--- Replaces running hilbish with `cmd`
--- @param cmd string
function hilbish.exec(cmd) end
function hilbish.exec() end
--- Checks if the `f` flag has been passed to Hilbish.
function hilbish.flag() end
--- Puts `fn` in a goroutine
--- @param fn function
function hilbish.goroutine(fn) end
function hilbish.goroutine() end
--- Runs the `cb` function every `time` milliseconds
--- @param cb function
--- @param time number
function hilbish.interval(cb, time) end
function hilbish.interval() end
--- Changes the continued line prompt to `str`
--- @param str string
function hilbish.mlprompt(str) end
function hilbish.mlprompt() end
--- Prepends `dir` to $PATH
function hilbish.prependPath() end
@ -47,22 +42,17 @@ function hilbish.prependPath() end
--- `%d` - Current working directory
--- `%u` - Name of current user
--- `%h` - Hostname of device
--- @param str string
function hilbish.prompt(str) end
function hilbish.prompt() 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
function hilbish.read(prompt) end
function hilbish.read() end
--- Runs `cmd` in Hilbish's sh interpreter.
--- @param cmd string
function hilbish.run(cmd) end
function hilbish.run() end
--- Runs the `cb` function after `time` in milliseconds
--- @param cb function
--- @param time number
function hilbish.timeout(cb, time) end
function hilbish.timeout() end
return hilbish

6
go.mod
View File

@ -3,16 +3,12 @@ module hilbish
go 1.16
require (
github.com/Rosettea/Hilbiline v0.0.0-20210624011007-8088a2d84b65
github.com/Rosettea/Hilbiline v0.0.0-20210710124707-aa6e3ff34cb2
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,5 +1,3 @@
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=