Command-Line Interface¶
The Kiwi CLI provides an interface for working with Kiwi files.
Basic Usage¶
Options¶
-h, --help¶
Displays help information with a summary of all available commands and their purposes.
-v, --version¶
Prints the current version.
-s, --settings¶
Prints the interpreter settings (for debugging).
-i, --interactive¶
Starts an interactive Read-Evaluate-Print Loop (REPL) where you can type and execute Kiwi code directly in the terminal.
The REPL also starts automatically when you run kiwi with no script and stdin is a terminal — -i is only needed when you want to force interactive mode explicitly (e.g. after loading a script).
To learn more about the REPL, please see REPL.
-e, --execute <code>¶
Executes a string of Kiwi code directly, without needing a file. The standard library is loaded as normal.
For multi-line code, use shell $'...' quoting with \n:
Key-value arguments can be passed alongside:
-d, --debug <input_file_path>¶
Runs a script under the kdb interactive debugger. Execution pauses at the first statement and presents a (kdb) prompt where you can step through the program, inspect variables, set breakpoints, and evaluate expressions.
To learn more, see kdb — Kiwi Debugger.
-c, --check <input_file_path>¶
Checks a script for syntax errors without executing it. All errors in the file are reported — not just the first one. Exits with code 0 if the file is clean, 1 if any errors were found.
Example output for a file with two errors:
[SyntaxError]: Unexpected token `*`.
File: script.kiwi:1:9
x = 1 + *
^
[SyntaxError]: Unexpected token `/`.
File: script.kiwi:2:9
y = 2 + /
^
Example output for a clean file:
-a, --ast <input_file_path>¶
Prints the abstract syntax tree of the input file.
-t, --tokens <input_file_path>¶
Tokenizes a file with the Kiwi lexer and prints the results to the standard output stream.
-n, --new <file_path>¶
Creates a new file with the .kiwi extension. If you don't include the extension in <file_path>, it will be appended automatically.
kiwi -n filename # Creates ./filename.kiwi
kiwi -n ../app # Creates ../app.kiwi in the parent directory
kiwi -n ./somedir/app # Creates ./somedir/app.kiwi in the specified subdirectory
Note: If a file with the same name already exists, the CLI will notify you to prevent accidental overwriting.
-sm, --safemode¶
Runs Kiwi in safe mode. This disables access to web, filesystem, and system shell functionality.
-ns, --no-stdlib¶
Runs Kiwi without loading its standard library.
-p, --stdlib-path <path>¶
Overrides the standard library path. Kiwi will load .kiwi files from the specified directory instead of the default stdlib location.
-cd, --crash-dump¶
Enables crash dump logging. When set, errors and unhandled exceptions are appended to kiwi_crash.log in the current directory. Without this flag, errors are only printed to stderr and no file is written.
The log path can also be set permanently via "crashdump_path" in kiwi-settings.json.
--tree-walker¶
Runs a script using the tree-walking interpreter instead of the default bytecode VM. This flag must appear before the script path. A script is required — running kiwi --tree-walker without one is an error.
-<key>=<value>¶
Sets a specific argument as a key-value pair, which can be used for various configuration purposes or to pass parameters into scripts.
Key-value arguments can also be passed without a script. When stdin is a terminal, the REPL starts and the arguments are available via env::argv():
If stdin is piped, the piped code is run with the arguments available as usual: