CLI
The nilakan command reads Nilakan source, runs it, prints program output to stdout, and prints
diagnostics to stderr. The installed nlk command is an alias with identical behavior.
nilakan [options] <file.nlk>nilakan [options] -nilakan [options] Read piped stdin when stdin is not a terminal.Replace nilakan with nlk in any invocation to use the short alias.
Inputs
Section titled “Inputs”| Form | Behavior |
|---|---|
nilakan program.nlk |
Reads a file. The path must end with .nlk. |
nilakan - |
Reads stdin. |
| piped stdin | Reads stdin when stdin is not a terminal. |
Imports
Section titled “Imports”A program can import other files. Imports resolve relative to the folder of the file that contains
them, so nilakan week3/main.nlk reads import shapes from week3/shapes.nlk. Imports in a
program read from stdin resolve from the current directory. Diagnostics in an imported file show
that file’s path. See Modules And Imports.
Options
Section titled “Options”| Option | Behavior |
|---|---|
-h, --help |
Print usage and exit successfully. |
--max-rounds NUMBER |
Override the global commit-round limit. |
--max-call-depth NUMBER |
Override the function call-depth limit. |
--max-loop-depth NUMBER |
Override the loop-depth limit. |
--max-prime-depth NUMBER |
Override the maximum source prime depth. |
--string-quotes STYLE |
Choose how strings are printed: double or single. |
--color MODE |
Control diagnostic color output: auto, always, or never. |
--figures-dir FOLDER |
Save printed figures in this folder. |
Numeric limits must be nonnegative safe integers from 0 through 9007199254740991. Decimal
fractions, exponent notation, negative values, and larger integer text are usage errors. Zero
prohibits the corresponding operation.
Default runtime limits:
| Option | Default |
|---|---|
--max-rounds |
100000 |
--max-call-depth |
100 |
--max-loop-depth |
100 |
--max-prime-depth |
5 |
Output
Section titled “Output”print(...) output is written to stdout. Diagnostics and usage errors are written to stderr.
When NO_COLOR is set in the environment, diagnostics are printed without color, even when color
mode is auto.
--string-quotes single changes printed string delimiters from double quotes to single quotes.
Containers and err(name, message, code) output use the same string quote style recursively.
--color always forces diagnostic color, --color never disables diagnostic color, and
--color auto uses terminal detection. NO_COLOR disables color when diagnostics are formatted.
Figures
Section titled “Figures”Printing a plot figure saves it as an SVG file instead of writing it to
stdout. Files are named after the program and numbered in print order: main.nlk writes
main-1.svg, main-2.svg, and so on, next to the program. A program read from stdin writes
figure-1.svg and onward in the current directory. --figures-dir FOLDER saves them in FOLDER
instead, creating it if needed. Each run overwrites files with the same names.
After saving a figure, the CLI writes figure: wrote <path> to stderr, so stdout keeps only printed
text. In a print call that mixes text and figures, the text still goes to stdout.
Usage Errors
Section titled “Usage Errors”The CLI exits with code 2 for usage errors:
- unknown option
- missing option value
- invalid nonnegative integer option value
- more than one positional input
- file path not ending in
.nlk - no file argument while stdin is a terminal
File-system failures are not usage errors. A missing file, directory path, permission failure, or
other read error prints error: could not read '<path>': <reason> and exits with code 1.
Exit Codes
Section titled “Exit Codes”| Code | Meaning |
|---|---|
0 |
Program ran successfully, or help was printed. |
1 |
Nilakan syntax/static/runtime error, or input file read failure. |
2 |
CLI usage error. |
Examples
Section titled “Examples”nilakan examples/hello.nlknilakan --string-quotes single examples/hello.nlknilakan --max-rounds 1000 examples/loop.nlkcat examples/hello.nlk | nilakan -Get-Content examples\hello.nlk | nilakan -type examples\hello.nlk | nilakan -