From 16bcd39a0a91b6018c14293c48767f882331fb9d Mon Sep 17 00:00:00 2001 From: Arsen Musayelyan Date: Mon, 1 Mar 2021 09:23:40 -0800 Subject: [PATCH] Add command --- cmd/scpt/main.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 cmd/scpt/main.go diff --git a/cmd/scpt/main.go b/cmd/scpt/main.go new file mode 100644 index 0000000..9fbd2c0 --- /dev/null +++ b/cmd/scpt/main.go @@ -0,0 +1,27 @@ +package main + +import ( + "flag" + "gitea.arsenm.dev/Arsen6331/scpt" + "log" + "os" +) + +func main() { + filePath := flag.String("file", "", "File to parse") + flag.Parse() + + if *filePath == "" { + log.Fatalln("Use --file to specify a file to parse") + } + + file, err := os.Open(*filePath) + if err != nil { + log.Fatalln("Error opening specified file:", err) + } + ast, err := scpt.Parse(file) + if err != nil { + log.Fatalln("Error parsing file:", err) + } + ast.Execute() +} \ No newline at end of file