mirror of https://github.com/Hilbis/Hilbish
feat: fallback to default config on error loading user conf
parent
3cb3b34023
commit
ef4975f984
12
lua.go
12
lua.go
|
@ -10,6 +10,13 @@ import (
|
||||||
"github.com/yuin/gopher-lua"
|
"github.com/yuin/gopher-lua"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var minimalconf = `
|
||||||
|
ansikit = require 'ansikit'
|
||||||
|
prompt(ansikit.text(
|
||||||
|
'{blue}%u {cyan}%d {green}∆{reset} '
|
||||||
|
))
|
||||||
|
`
|
||||||
|
|
||||||
func LuaInit() {
|
func LuaInit() {
|
||||||
l = lua.NewState()
|
l = lua.NewState()
|
||||||
|
|
||||||
|
@ -56,7 +63,10 @@ func LuaInit() {
|
||||||
// Run config
|
// Run config
|
||||||
err = l.DoFile(homedir + "/.hilbishrc.lua")
|
err = l.DoFile(homedir + "/.hilbishrc.lua")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
fmt.Fprintln(os.Stderr, err,
|
||||||
|
"An error has occured while loading your config! Falling back to minimal default config.\n")
|
||||||
|
|
||||||
|
l.DoString(minimalconf)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue