diff --git a/lua.go b/lua.go index 27ed751..7919a75 100644 --- a/lua.go +++ b/lua.go @@ -2,12 +2,12 @@ package main import ( "fmt" - hooks "hilbish/golibs/bait" - cmds "hilbish/golibs/commander" + "hilbish/golibs/bait" + "hilbish/golibs/commander" lfs "hilbish/golibs/fs" "os" - lua "github.com/yuin/gopher-lua" + "github.com/yuin/gopher-lua" ) var minimalconf = ` @@ -32,9 +32,9 @@ func LuaInit(confpath string) { // Add fs module to Lua l.PreloadModule("fs", lfs.Loader) - commander := cmds.New() + cmds := commander.New() // When a command from Lua is added, register it for use - commander.Events.On("commandRegister", + cmds.Events.On("commandRegister", func(cmdName string, cmd *lua.LFunction) { commands[cmdName] = true l.SetField( @@ -44,10 +44,10 @@ func LuaInit(confpath string) { cmd) }) - l.PreloadModule("commander", commander.Loader) + l.PreloadModule("commander", cmds.Loader) - bait = hooks.New() - l.PreloadModule("bait", bait.Loader) + hooks = bait.New() + l.PreloadModule("bait", hooks.Loader) // Add more paths that Lua can require from l.DoString(`package.path = package.path diff --git a/main.go b/main.go index adcf71f..fdaa1bc 100644 --- a/main.go +++ b/main.go @@ -8,7 +8,7 @@ import ( "os/user" "strings" - hooks "hilbish/golibs/bait" + "hilbish/golibs/bait" "github.com/akamensky/argparse" "github.com/bobappleyard/readline" @@ -28,7 +28,7 @@ var ( commands = map[string]bool{} aliases = map[string]string{} - bait hooks.Bait + hooks bait.Bait homedir string running bool interactive bool diff --git a/shell.go b/shell.go index be5029f..afefe89 100644 --- a/shell.go +++ b/shell.go @@ -23,7 +23,7 @@ func RunInput(input string) { // If it succeeds, add to history and prompt again HandleHistory(input) - bait.Em.Emit("command.exit", 0) + hooks.Em.Emit("command.exit", 0) return } @@ -71,22 +71,22 @@ func RunInput(input string) { if syntax.IsIncomplete(err) || strings.HasSuffix(input, "\\") { continue } else if code, ok := interp.IsExitStatus(err); ok { - bait.Em.Emit("command.exit", code) + hooks.Em.Emit("command.exit", code) } else if err != nil { fmt.Fprintln(os.Stderr, err) - bait.Em.Emit("command.exit", 1) + hooks.Em.Emit("command.exit", 1) } break } } else { if code, ok := interp.IsExitStatus(err); ok { - bait.Em.Emit("command.exit", code) + hooks.Em.Emit("command.exit", code) } else { fmt.Fprintln(os.Stderr, err) } } } else { - bait.Em.Emit("command.exit", 0) + hooks.Em.Emit("command.exit", 0) } HandleHistory(cmdString) }