JANET(1)

NAME
janet - run the Janet language abstract machine

SYNOPSIS
janet [-hvsrpnqik] [-e SOURCE] [-E SOURCE ...ARGUMENTS] [-l MODULE] [-m PATH] [-c MODULE JIMAGE] [-w LEVEL] [-x LEVEL] [--] script args...

DESCRIPTION
Janet is a functional and imperative programming language and bytecode interpreter. It is a Lisp-like language, but lists are replaced by other data structures (arrays, tables, structs, tuples). The language also features bridging to native code written in C, meta-programming with macros, and bytecode assembly.

There is a repl for trying out the language, as well as the ability to run script files. This client program is separate from the core runtime, so Janet could be embedded into other programs. Try Janet in your browser at https://janet-lang.org.

Implemented in mostly standard C99, Janet runs on Windows, Linux and macOS. The few features that are not standard C99 (dynamic library loading, compiler specific optimizations), are fairly straight forward. Janet can be easily ported to most new platforms.

REPL KEY-BINDINGS

Home
    Move cursor to the beginning of input line.

End Move cursor to the end of input line.

Left/Right
    Move cursor in input line.

Up/Down
    Go backwards and forwards through history.

Tab Complete current symbol, or show available completions.

Delete
    Delete one character after the cursor.

Backspace
    Delete one character before the cursor.

Ctrl-A
    Move cursor to the beginning of input line.

Ctrl-B
    Move cursor one character to the left.

Ctrl-D
    If on a newline, indicate end of stream and exit the repl.

Ctrl-E
    Move cursor to the end of input line.

Ctrl-F
    Move cursor one character to the right.

Ctrl-H
    Delete one character before the cursor.

Ctrl-K
    Delete everything after the cursor on the input line.

Ctrl-L
    Clear the screen.

Ctrl-N/Ctrl-P
    Go forwards and backwards through history.

Ctrl-U
    Delete everything before the cursor on the input line.

Ctrl-W
    Delete one word before the cursor.

Ctrl-G
    Show documentation for the current symbol under the cursor.

Ctrl-Q
    Clear the current command, including already typed lines.

Alt-B/Alt-F
    Move cursor backwards and forwards one word.

Alt-D
    Delete one word after the cursor.

Alt-,
    Go to earliest item in history.

Alt-.
    Go to last item in history.

The repl keybindings are loosely based on a subset of GNU readline, although Janet does not use GNU readline internally for the repl. It is a limited substitute for GNU readline, and does not handle utf-8 input or other mutlibyte input well.

To disable the built-in repl input handling, pass the -s option to Janet, and use a program like rlwrap with Janet to provide input.

For key bindings that operate on words, a word is considered to be a sequence of characters that does not contain whitespace.

DOCUMENTATION

For more complete API documentation, run a REPL (Read Eval Print Loop), and use the doc macro to see documentation on individual bindings.

OPTIONS

-h  Shows the usage text and exits immediately.

-v  Shows the version text and exits immediately.

-s  Read raw input from stdin and forgo fancy input, which includes prompt history and other readline-like features.

-e code
    Execute a string of Janet source. Source code is executed in the order it is encountered, so earlier arguments are executed before later ones.

-E code arguments...
    Execute a single Janet expression as a Janet short-fn, passing the remaining command line arguments to the expression. This allows more concise one-liners with command line arguments.

    Example: janet -E '(print $0)' 12 is equivalent to '((short-fn (print $0)) 12)', which is in turn equivalent to `((fn [k] (print k)) 12)`

    See docs for the `short-fn` function for more details.

-d  Enable debug mode. On all terminating signals as well the debug signal, this will cause the debugger to come up in the REPL. Same as calling (setdyn :debug true) in a default repl.

-n  Disable ANSI colors in the repl. Has no effect if no repl is run.

-N  Enable ANSI colors in the repl. Has no effect if no repl is run.

-r  Open a REPL (Read Eval Print Loop) after executing all sources. By default, if Janet is called with no arguments, a REPL is opened.

-R  If using the REPL, disable loading the user profile from the JANET_PROFILE environment variable.

-p  Turn on the persistent flag. By default, when Janet is executing commands from a file and encounters an error, it will immediately exit after printing the error message. In persistent mode, Janet will keep executing commands after an error. Persistent mode can be good for debugging and testing.

-q  Hide the logo in the repl.

-k  Don't execute a script, only compile it to check for errors. Useful for linting scripts.

-m syspath
    Set the dynamic binding :syspath to the string syspath so that Janet will load system modules from a directory different than the default. The default is set when Janet is built, and defaults to /usr/local/lib/janet on Linux/Posix. On Windows, there is no default value. This option supersedes JANET_PATH.

-c source output
    Precompiles Janet source code into an image, a binary dump that can be efficiently loaded later. Source should be a path to the Janet module to compile, and output should be the file path of resulting image. Output should usually end with the .jimage extension.

-i  When this flag is passed, a script passed to the interpreter will be treated as a janet image file rather than a janet source file.

-l lib
    Import a Janet module before running a script or repl. Multiple files can be loaded in this manner, and exports from each file will be made available to the script or repl.

-w level
    Set the warning linting level for Janet. This linting level should be one of :relaxed, :none, :strict, :normal, or a Janet number. Any linting message that is of a greater lint level than this setting will be displayed as a warning, but not stop compilation or execution.

-x level
    Set the error linting level for Janet. This linting level should be one of :relaxed, :none, :strict, :normal, or a Janet number. Any linting message that is of a greater lint level will cause a compilation error and stop compilation.

--  Stop parsing command line arguments. All arguments after this one will be considered file names and then arguments to the script.

ENVIRONMENT

JANET_PATH
    The location to look for Janet libraries. This is the only environment variable Janet needs to find native and source code modules. If no JANET_PATH is set, Janet will look in the default location set at compile time. This should be a colon-separated list of directory names on Linux/Posix, and a semicolon-separated list on Windows. Note that a typical setup (i.e. not NixOS / Guix) will only use a single directory.

JANET_PROFILE
    Path to a profile file that the interpreter will load before entering the REPL. This profile file will not run for scripts, though. This behavior can be disabled with the -R option.

JANET_HASHSEED
    To disable randomization of Janet's PRF on start up, one can set this variable. This can have the effect of making programs deterministic that otherwise would depend on the random seed chosen at program start. This variable does nothing in the default configuration of Janet, as PRF is disabled by default. Also, JANET_REDUCED_OS cannot be defined for this variable to have an effect.

JANET_HISTFILE
    A file location to use for the default shell's REPL history when using fancy input. This relative path is where commands are persisted between sessions. If unset, no repl history well be used. Does not work with the -s flag where fancy input is disabled.

NO_COLOR
    Turn off color by default in the repl and in the error handler of scripts. This can be changed at runtime via dynamic bindings *err-color* and *pretty-format*, or via the command line parameters -n and -N.

AUTHOR
Written by Calvin Rose <calsrose@gmail.com>