Moonshark/moonshark.go

33 lines
577 B
Go

package main
import (
"fmt"
"os"
"path/filepath"
"Moonshark/state"
)
func main() {
if len(os.Args) < 2 {
fmt.Fprintf(os.Stderr, "Usage: %s <script.lua>\n", filepath.Base(os.Args[0]))
os.Exit(1)
}
scriptPath := os.Args[1]
// Create state configured for the script
luaState, err := state.NewFromScript(scriptPath)
if err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)
}
defer luaState.Close()
// Execute the script
if err := luaState.ExecuteFile(scriptPath); err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)
}
}