2
2
spogulis no https://github.com/Hilbis/Hilbish synced 2025-07-14 14:52:02 +00:00

Salīdzināt revīzijas

..

5 Revīzijas

Autors SHA1 Ziņojums Datums
sammyette
e37abcb08b
feat: define preload file in var
same as before, enables changing at compile time
2021-06-08 21:00:31 -04:00
sammyette
be5ebd6ada
feat: add back cancel input on ctrl c 2021-06-08 21:00:01 -04:00
sammyette
86dbb97cae
feat: define lua require paths in var
this makes it able to be changed compile time, which should help
in support for systems that dont follow fhs (damn nix)
and windows as well, but that'll be first class
2021-06-08 19:16:37 -04:00
sammyette
2a084fc03e
fix: make minimal config work with new version 2021-06-08 17:40:52 -04:00
sammyette
ef45bafb54
fix: remove extra newline in error message 2021-06-08 17:24:54 -04:00
5 mainīti faili ar 40 papildinājumiem un 23 dzēšanām

17
lua.go
Parādīt failu

@ -16,8 +16,8 @@ import (
) )
var minimalconf = ` var minimalconf = `
ansikit = require 'ansikit' lunacolors = require 'lunacolors'
prompt(ansikit.format( prompt(lunacolors.format(
'{blue}%u {cyan}%d {green}{reset} ' '{blue}%u {cyan}%d {green}{reset} '
)) ))
` `
@ -58,18 +58,11 @@ func LuaInit() {
l.PreloadModule("bait", hooks.Loader) l.PreloadModule("bait", hooks.Loader)
// Add more paths that Lua can require from // Add more paths that Lua can require from
l.DoString(`package.path = package.path l.DoString("package.path = package.path .. " + requirePaths)
.. ';./libs/?/init.lua;./?/init.lua;./?/?.lua'
.. ';/usr/share/hilbish/libs/?/init.lua;'
.. ';/usr/share/hilbish/libs/?/?.lua;'
.. os.getenv 'HOME' .. '/.local/share/hilbish/libs/?/init.lua;'
.. os.getenv 'HOME' .. '/.local/share/hilbish/libs/?/?.lua;'
.. os.getenv 'HOME' .. '/.local/share/hilbish/libs/?.lua'
`)
err := l.DoFile("preload.lua") err := l.DoFile("preload.lua")
if err != nil { if err != nil {
err = l.DoFile("/usr/share/hilbish/preload.lua") err = l.DoFile(preloadPath)
if err != nil { if err != nil {
fmt.Fprintln(os.Stderr, fmt.Fprintln(os.Stderr,
"Missing preload file, builtins may be missing.") "Missing preload file, builtins may be missing.")
@ -83,7 +76,7 @@ func RunConfig(confpath string) {
err := l.DoFile(confpath) err := l.DoFile(confpath)
if err != nil { if err != nil {
fmt.Fprintln(os.Stderr, err, fmt.Fprintln(os.Stderr, err,
"\nAn error has occured while loading your config! Falling back to minimal default config.\n") "\nAn error has occured while loading your config! Falling back to minimal default config.")
l.DoString(minimalconf) l.DoString(minimalconf)
} }

12
main.go
Parādīt failu

@ -18,26 +18,17 @@ import (
"golang.org/x/term" "golang.org/x/term"
) )
var ( var (
version = "v0.4.0"
l *lua.LState l *lua.LState
lr *LineReader lr *LineReader
prompt string // User's prompt, this will get set when lua side is initialized
multilinePrompt = "> "
commands = map[string]bool{} commands = map[string]bool{}
aliases = map[string]string{} aliases = map[string]string{}
homedir string homedir string
curuser *user.User curuser *user.User
running bool // Is a command currently running
hooks bait.Bait hooks bait.Bait
interactive bool
login bool // Are we the login shell?
noexecute bool // Should we run Lua or only report syntax errors
) )
func main() { func main() {
@ -227,8 +218,7 @@ func HandleSignals() {
for range c { for range c {
if !running { if !running {
//readline.ReplaceLine("", 0) lr.ClearInput()
//readline.RefreshLine()
} }
} }
} }

5
rl.go
Parādīt failu

@ -34,3 +34,8 @@ func (lr *LineReader) AddHistory(cmd string) {
readline.SaveHistory(homedir + "/.hilbish-history") readline.SaveHistory(homedir + "/.hilbish-history")
} }
func (lr *LineReader) ClearInput() {
readline.ReplaceLine("", 0)
readline.RefreshLine()
}

Parādīt failu

@ -32,3 +32,7 @@ func (lr *LineReader) AddHistory(cmd string) {
return return
} }
func (lr *LineReader) ClearInput() {
return
}

25
vars.go Parasts fails
Parādīt failu

@ -0,0 +1,25 @@
package main
// String vars that are free to be changed at compile time
var (
version = "v0.4.0"
requirePaths = `';./libs/?/init.lua;./?/init.lua;./?/?.lua'
.. ';/usr/share/hilbish/libs/?/init.lua;'
.. ';/usr/share/hilbish/libs/?/?.lua;'
.. os.getenv 'HOME' .. '/.local/share/hilbish/libs/?/init.lua;'
.. os.getenv 'HOME' .. '/.local/share/hilbish/libs/?/?.lua;'
.. os.getenv 'HOME' .. '/.local/share/hilbish/libs/?.lua'`
preloadPath = "/usr/share/hilbish/preload.lua"
prompt string // Prompt will always get changed anyway
multilinePrompt = "> "
)
// Flags
var (
running bool // Is a command currently running
interactive bool
login bool // Are we the login shell?
noexecute bool // Should we run Lua or only report syntax errors
)