Skip to content
This repository was archived by the owner on Aug 2, 2023. It is now read-only.

[WIP] Feature/improve cli support #38

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
build:
go build -o glua ./cmd/glua
mv ./glua "$$GOPATH/bin"

tests:
bash test/test.sh
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
20 changes: 19 additions & 1 deletion cmd/glua/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)}
Expand Down