Add command
This commit is contained in:
		
							
								
								
									
										27
									
								
								cmd/scpt/main.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								cmd/scpt/main.go
									
									
									
									
									
										Normal file
									
								
							@@ -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()
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user