Skip to content

CLI Tool

Arkin Solomon edited this page Feb 7, 2023 · 6 revisions

General

Sakura will automatically print out the return value of the script, or nothing if the script does not return anything. It will also send print statements to STDOUT and error messages to STDERR. A customer error code thrown using exit() from within the script will cause the command to error with the provided error code. Note that the command requires a flag to execute.

Running Code

The interpreter supports running a string of text using the -e or --execute flag.

$ ska-java -e "print(\"Hello\")"
Hello
$ echo $? 
0
$ ska-java -e "exit(5)"
[1:1] Script execution terminated (code 5): <unknown reason>
$ echo $? 
5

Note that you should be careful when using certain chars. For instance trying to declare a variable using $ may error since most command lines will assume it to be a variable. If this occurs prefix it with a backslash.

Running a File

To run a Sakura file using the CLI tool, use the -f or --file flag followed by the name. For instance:

$ ska-java -f myFile.ska

This outputs the same values as the CLI tool.

Configuration

Configuration using the CLI tool is done in JSON and passed using the -c or --config flags. There are many top-level properties that the interpreter accepts.

executor

The executor property expects a string with the value to be passed as the executor. If this is omitted the executor is declared "unknown".

root

The root property expects a string which is the path to the file to be considered as the root. If it is not provided, it is assumed to be the current working directory.

allowRead | disallowRead | allowWrite | disallowWrite

These properties all expect arrays of strings corresponding to the file restrictions page. If not provided, it is assumed to be blank. Note that this means if no read or write permissions are changed, no access will be granted to the script.

Clone this wiki locally