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 b743a2c..b98aa28 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,36 @@ 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. + +# 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 333f1e1..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) { @@ -31,7 +44,12 @@ func init() { func main() { if flag.NArg() < 1 { - must(fmt.Errorf("missing arguments")) + must(fmt.Errorf("Missing arguments")) + } + + if flag.Args()[0] == "help" { + fmt.Println(usage) + os.Exit(0) } var opts = []lua.Option{lua.WithTrace(trace), lua.WithVerbose(debug)}