-
Notifications
You must be signed in to change notification settings - Fork 0
CLI Tool
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.
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.
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 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.
The executor
property expects a string with the value to be passed as the executor. If this is omitted the executor is declared "unknown".
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.
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.
Sakura Interpreter Java © 2023 Arkin Solomon. Licensed under Apache-2.0.