From bd6d8b62e9c19664bfa7f45d9d7f6adb6f8c6df7 Mon Sep 17 00:00:00 2001 From: Igor Franca Date: Sat, 17 Nov 2018 00:17:55 -0200 Subject: [PATCH 1/2] Added the 'help' command, for now without Cobra framework, and improved the documentation to execute the 'glua' interpreter --- README.md | 5 +++++ cmd/glua/main.go | 15 ++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b743a2c..affb67f 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,10 @@ WARNING! Please expect breaking changes and unstable APIs. Most of them are currently at an early, experimental stage. +# CLI usage + +`glua` is the binary that calls the interpreter to run your `.lua` files, check the `glua help` for all the +flags and the options about running files. + # Contributing This project welcomes contributions and suggestions. Most contributions require you to agree to a diff --git a/cmd/glua/main.go b/cmd/glua/main.go index 333f1e1..96d3f8a 100644 --- a/cmd/glua/main.go +++ b/cmd/glua/main.go @@ -31,7 +31,20 @@ func init() { func main() { if flag.NArg() < 1 { - must(fmt.Errorf("missing arguments")) + must(fmt.Errorf("Missing arguments")) + } + + if flag.Args()[0] == "help" { + fmt.Printfn(` + glua [flags] [files] + flags available: + -debug: boolean -> Set it to true to enable verbose logging + -trace: boolean -> Set it to true to enable tracing + -tests: boolean -> This will run all the tests of the engine + + files: + Pass the path for the script to be executed. + `) } var opts = []lua.Option{lua.WithTrace(trace), lua.WithVerbose(debug)} From 39a3b39d8446eb1a110615ffff7d0870290d00c6 Mon Sep 17 00:00:00 2001 From: Igor Franca Date: Sat, 17 Nov 2018 00:42:57 -0200 Subject: [PATCH 2/2] Added the 'Makefile' to use the make build tool to automate the build inside different environments, added some documentation about the CLI usage, the development envionment necessary to run the project. And added the help command inside the usage output. --- Makefile | 6 ++++++ README.md | 24 ++++++++++++++++++++++++ cmd/glua/main.go | 25 +++++++++++++++---------- 3 files changed, 45 insertions(+), 10 deletions(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..ad49564 --- /dev/null +++ b/Makefile @@ -0,0 +1,6 @@ +build: + go build -o glua ./cmd/glua + mv ./glua "$$GOPATH/bin" + +tests: + bash test/test.sh \ No newline at end of file diff --git a/README.md b/README.md index affb67f..b98aa28 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,32 @@ WARNING! Please expect breaking changes and unstable APIs. Most of them are curr `glua` is the binary that calls the interpreter to run your `.lua` files, check the `glua help` for all the flags and the options about running files. +# Building the CLI from source + +For Linux/macOS environments: + You should have the `make` build tool to build the `glua` command line interface. + After installing, just go to the root directory of this project, and run: + + `make build` + + This command will create a binary named `glua`, and move it to your `$GOPATH/bin` directory + If you want to use somewhere else in your computer, please, add the `$GOPATH/bin` directory + to your `PATH` environment variable. + + # Contributing +## Prerequisites: + `luac`: You must have Lua compiled for your distribution. + `make`: You must have the build tool already installed. + `go`: You must have at least the Golang >= 1.11.2 to run the source code and tests. + +## Testing the installation + +This project have a extensive series of automated tests to make sure everything runs fine in your environment, +you just have to use the `make tests` command to run all the tests. + + This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com. diff --git a/cmd/glua/main.go b/cmd/glua/main.go index 96d3f8a..9c8bb77 100644 --- a/cmd/glua/main.go +++ b/cmd/glua/main.go @@ -13,6 +13,19 @@ var ( trace bool = false debug bool = false tests bool = false + usage string = ` +glua [flags] [files] + flags available: + -debug: boolean -> Set it to true to enable verbose logging + -trace: boolean -> Set it to true to enable tracing + -tests: boolean -> This will run all the tests of the engine + + files: + Pass the path for the script to be executed. + +glua help + Print this usage and exit. + ` ) func must(err error) { @@ -35,16 +48,8 @@ func main() { } if flag.Args()[0] == "help" { - fmt.Printfn(` - glua [flags] [files] - flags available: - -debug: boolean -> Set it to true to enable verbose logging - -trace: boolean -> Set it to true to enable tracing - -tests: boolean -> This will run all the tests of the engine - - files: - Pass the path for the script to be executed. - `) + fmt.Println(usage) + os.Exit(0) } var opts = []lua.Option{lua.WithTrace(trace), lua.WithVerbose(debug)}