feat: fallback to default config on error loading user conf

pull/24/head
TorchedSammy 2021-04-04 20:31:32 -04:00
parent 3cb3b34023
commit ef4975f984
1 changed files with 11 additions and 1 deletions

12
lua.go
View File

@ -10,6 +10,13 @@ import (
"github.com/yuin/gopher-lua"
)
var minimalconf = `
ansikit = require 'ansikit'
prompt(ansikit.text(
'{blue}%u {cyan}%d {green}{reset} '
))
`
func LuaInit() {
l = lua.NewState()
@ -56,7 +63,10 @@ func LuaInit() {
// Run config
err = l.DoFile(homedir + "/.hilbishrc.lua")
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)
}
}