From 18b11177494c4704acc17586e7527d8e6ed9e941 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Fri, 3 Dec 2021 23:28:12 +0100 Subject: Renamed headless_interpreter to gofunge98 --- README.md | 10 ++++----- cmd/gofunge98/main.go | 44 ++++++++++++++++++++++++++++++++++++++++ cmd/headless_interpreter/main.go | 44 ---------------------------------------- 3 files changed, 49 insertions(+), 49 deletions(-) create mode 100644 cmd/gofunge98/main.go delete mode 100644 cmd/headless_interpreter/main.go diff --git a/README.md b/README.md index b366ad1..ddf0dbc 100644 --- a/README.md +++ b/README.md @@ -22,14 +22,14 @@ go is required. Only go version >= 1.17 on linux amd64 (Gentoo) is being regular ## Quick Install ``` -go install git.adyxax.org/adyxax/gofunge98/cmd/headless_interpreter@latest +go install git.adyxax.org/adyxax/gofunge98/cmd/gofunge98@latest ``` ## Usage -Launching the headless_interpreter is as simple as : +Launching the gofunge98 is as simple as : ``` -headless_interpreter -f something.b98 +gofunge98 -f something.b98 ``` The interpreter will then load and execute the specified Funge-98 program until the program normally terminates or is interrupted or killed. @@ -43,10 +43,10 @@ go test -cover ./... For a debug build, use : ``` -go build ./cmd/headless_interpreter/ +go build ./cmd/gofunge98/ ``` For a release build, use : ``` -go build -ldflags '-s -w -extldflags "-static"' ./cmd/headless_interpreter/ +go build -ldflags '-s -w -extldflags "-static"' ./cmd/gofunge98/ ``` diff --git a/cmd/gofunge98/main.go b/cmd/gofunge98/main.go new file mode 100644 index 0000000..3d2329a --- /dev/null +++ b/cmd/gofunge98/main.go @@ -0,0 +1,44 @@ +package main + +import ( + "flag" + "fmt" + "os" + + "git.adyxax.org/adyxax/gofunge98/pkg/field" + "git.adyxax.org/adyxax/gofunge98/pkg/interpreter" + "git.adyxax.org/adyxax/gofunge98/pkg/pointer" +) + +func main() { + filename := flag.String("f", "", "b98 file to interpret") + help := flag.Bool("h", false, "display this help message") + flag.Parse() + + if *help { + flag.Usage() + os.Exit(0) + } + + if *filename == "" { + fmt.Println("Error : no b98 file to interpret") + flag.Usage() + os.Exit(1) + } + file, err := os.Open(*filename) + if err != nil { + fmt.Printf("Failed to open file %s : %+v", *filename, err) + os.Exit(2) + } + defer file.Close() + + f, err := field.Load(file) + if err != nil { + fmt.Printf("Failed to load file %s : %+v", *filename, err) + os.Exit(3) + } + p := pointer.NewPointer() + p.Argv = []string{*filename} + v := interpreter.NewInterpreter(f, p).Run() + os.Exit(v) +} diff --git a/cmd/headless_interpreter/main.go b/cmd/headless_interpreter/main.go deleted file mode 100644 index 3d2329a..0000000 --- a/cmd/headless_interpreter/main.go +++ /dev/null @@ -1,44 +0,0 @@ -package main - -import ( - "flag" - "fmt" - "os" - - "git.adyxax.org/adyxax/gofunge98/pkg/field" - "git.adyxax.org/adyxax/gofunge98/pkg/interpreter" - "git.adyxax.org/adyxax/gofunge98/pkg/pointer" -) - -func main() { - filename := flag.String("f", "", "b98 file to interpret") - help := flag.Bool("h", false, "display this help message") - flag.Parse() - - if *help { - flag.Usage() - os.Exit(0) - } - - if *filename == "" { - fmt.Println("Error : no b98 file to interpret") - flag.Usage() - os.Exit(1) - } - file, err := os.Open(*filename) - if err != nil { - fmt.Printf("Failed to open file %s : %+v", *filename, err) - os.Exit(2) - } - defer file.Close() - - f, err := field.Load(file) - if err != nil { - fmt.Printf("Failed to load file %s : %+v", *filename, err) - os.Exit(3) - } - p := pointer.NewPointer() - p.Argv = []string{*filename} - v := interpreter.NewInterpreter(f, p).Run() - os.Exit(v) -} -- cgit v1.2.3