Skip to content
Jennifer Programming Language

CLI (cmd/jennifer)

jennifer run [flags] <file.j> [args...]  run a Jennifer program
jennifer run -             read source from stdin
jennifer repl              interactive REPL
jennifer tokens <file.j>   dump the lexer's token stream
jennifer ast <file.j>      dump the preprocessed AST as JSON
jennifer fmt [-w|-l] <file.j>...  format source per style-guide.md (-w rewrites in place, -l lists unformatted files)
jennifer lint <file.j>...  report compile-legal but suspect patterns
jennifer profile <file.j>  run with the evaluator instrumented; write a profile
jennifer test <file.j>     discover and run the file's test functions
jennifer serve <file.j>    run a program (--watch re-runs it on change)
jennifer version [-v]      print the build version (-v adds module-path layers)
jennifer help              show usage

--version and -v are aliases of version; -h and --help of help.

Subcommand reference

The jennifer binary bundles the interpreter with its development toolchain: REPL, formatter, linter, profiler, test runner, and token / AST inspection. Each subcommand has its own page. The development subcommands (tokens, ast, fmt, lint, profile, test) and serve live in the default jennifer binary only (the run-only jennifer-tiny build stubs them; serve runs a net-backed web app); run, repl, and version work in both binaries.

jennifer-tiny-dev is for CI: jennifer-tiny built with the tinygo_devtools tag, so it has the constrained runtime (same stack, same caps, same stubbed libraries) plus tokens, ast, fmt, lint, profile and test. Deck CI runs jennifer-tiny-dev test on a deck's overlays to check its jennifer-tiny claim. serve and test --isolated are not available there. Only the container images carry it (see TinyGo notes).

SubcommandWhat it doesDetails
run <file.j>Run a Jennifer program (- reads source from stdin).Module resolution flags
replInteractive read-eval-print loop, with a line editor and history.REPL
tokens <file.j>Dump the lexer's token stream.Inspection
ast <file.j>Dump the preprocessed AST as JSON.Inspection
fmt [-w|-l] <file.j>...Format source per the style guide (stdout; -w/--write rewrites in place, -l/--check lists unformatted files).Formatter
lint <file.j>...Report compile-legal but suspect patterns.Linter
profile <file.j>Run the program instrumented; per-statement or per-function hits and timings.Profiler
test <file.j>Discover and run the file's test functions.Test runner
serve <file.j>Run a program; --watch re-runs it on change (a web-app reloader, or an autorun loop for any script).The serve command
version [-v]Print the build version (-v adds module-path layers).Version injection
helpShow usage.-

Module resolution flags (run)

jennifer run accepts interpreter flags before the source file; anything after the file is the program's own os.ARGS.

  • --sysmoddir DIR (or --sysmoddir=DIR) - the system module directory for bare import "name.j";. Overrides JENNIFER_SYSMODDIR, which overrides the build default (<PREFIX>/share/jennifer/modules, see make PREFIX=). A named (CLI or env) dir that is missing or not a directory refuses to start; the build default is best-effort. The resolved value is meta.SYSMODDIR.
  • -I DIR (or -I=DIR, repeatable) - add a directory to the module search path after the system dir. A -I dir adds names; a module name appearing in two search dirs is a hard error at load. (Resolution lives in internal/module; the import statement consumes it via the loader wired in main.go's runFile - in.EnableModules(baseDir, searchDirs, loadModuleProgram, installLibraries), where searchDirs is the system dir followed by each -I dir.)
  • --vendor DIR (or --vendor=DIR) - the vendor root for @scope/package deck imports. Overrides JENNIFER_VENDOR, which overrides the upward walk to the nearest vendor/ directory above the program. @scope/package/ expands to <vendorRoot>/scope/package/package.j (see the import spec); wired via in.SetVendorRoot(module.FindVendorRoot(vendorFlag, baseDir)). repl / test use the upward walk (no flag).
  • --env PROFILE (or --env=PROFILE) - a run profile, pure sugar that sets JENNIFER_ENV=PROFILE in the process environment before Run, so jennifer run --env=prod app.j is identical to JENNIFER_ENV=prod jennifer run app.j. No interpreter change - the program reads the profile from the one env var (the dotenv module's .env.<profile> selection is the first consumer). The label is validated ([A-Za-z0-9_-], 1-64 chars, mirroring dotenv's own validProfile), which also blocks a .env.<profile> path traversal; an explicit --env overrides any inherited JENNIFER_ENV. Parsed in main.go's parseRunArgs / validRunProfile.

jennifer version -v (also -vv..., --verbose) reports the install prefix the binary was built for (make PREFIX=, M29.4) and every path the interpreter uses, each with where it came from (a flag, the environment, the build, or the system):

LineLayers
prefixthe build
system module dir--sysmoddir, JENNIFER_SYSMODDIR, the build (<PREFIX>/share/jennifer/modules)
docs dirthe build (<PREFIX>/share/doc/jennifer)
resolv.conf, hostsJENNIFER_RESOLV_CONF / JENNIFER_HOSTS, <PREFIX>/etc, /etc (M29.5; the candidates looked for are listed)
temp dirTMPDIR, the system default
vendor rootJENNIFER_VENDOR, the nearest vendor/ above the current directory
text
jennifer 0.27.0
prefix: /usr (build)
system module dir: /usr/share/jennifer/modules (build)
  build default: /usr/share/jennifer/modules
docs dir: /usr/share/doc/jennifer (build)
resolv.conf: /etc/resolv.conf (system)
  looked for: JENNIFER_RESOLV_CONF (unset), /etc/resolv.conf
hosts: /etc/hosts (system)
  looked for: JENNIFER_HOSTS (unset), /etc/hosts
temp dir: /tmp (system default)
vendor root: (none; no JENNIFER_VENDOR and no vendor/ above cwd)

The prefix is written into internal/version/version_gen.go by scripts/gen-version.sh (an init(), since TinyGo ignores -ldflags -X); internal/version/paths.go derives every built-in path from it, so no other Go code names /usr or /etc.

jennifer run:

  • Verifies the .j extension - unless the file's first line is a #! shebang, in which case any name is accepted (so an executable script installed under a bare command name, e.g. /usr/bin/mytool, runs without a .j suffix). Only the entry point is exempt; import / include targets still require .j.
  • Reads the file, parses, runs
  • On error: prints the message and a source-context caret on stderr, exits 1
  • Bad usage exits 2
  • jennifer help includes a Version: line identifying the build

The serve command

jennifer serve <file.j> runs a program the same way run does - there is no entry point, so the file's top-level executes in order and serving happens only because the program itself calls web.run(...). On its own, serve adds only a banner (printed after a clean parse). Its reason to exist is --watch. Flags may appear before or after the file: --watch, --sysmoddir DIR and -I DIR (passed on to the child run); serve takes no program arguments.

sh
jennifer serve app.j            # run the app
jennifer serve app.j --watch    # re-run on every change to the entry file

With --watch, serve runs the program in a child process and restarts it whenever the entry file changes: it polls the file's modification time every 400 ms and, on a change, kills the child and starts a fresh one. Ctrl-C stops the loop.

Two uses fall out of the same mechanism:

  • A web-app reloader. A long-running web.run server never exits on its own; save a handler and --watch restarts it against the new code - the Hugo-style edit / reload loop.
  • A general autorun loop. For a program that finishes (any script, not just a server), the child exits, serve prints app exited; waiting for a change to reload..., and parks until the next edit - so jennifer serve --watch script.j is an edit-and-rerun harness for anything: save, see the output, save again. The watcher deliberately stays alive after a clean exit (a loop that quit the moment a server died on a syntax error would defeat the point).

Only the entry file is watched - changes to included files or imported modules do not trigger a reload. serve is default-binary-only (the httpd engine is net-backed, and --watch uses os/exec); see the web module.

Shell pipelines and aliases

jennifer run - reads the program from stdin, so Jennifer works in a shell pipeline like any other filter. Stdin can carry either the program or the data, not both. So a one-liner alias pipes the program in and passes the data as an argument (read back through os.ARGS); a reusable filter keeps the program in a file and leaves stdin free for the data.

Inline, program piped via run -. A json-pretty that reformats a single JSON argument. The program arrives on stdin, so the JSON is os.ARGS[1] (ARGS[0] is the -):

sh
alias json-pretty="printf '%s' 'use json; use os; use io; io.printf(\"%s\\n\", json.encodePretty(json.decode(os.ARGS[1])));' | jennifer run -"

json-pretty '{"b":2,"a":1}'
# {
#   "b": 2,
#   "a": 1
# }

Use printf '%s' rather than echo to pass the program verbatim, so the \n reaches Jennifer as a two-character escape instead of being expanded by the shell.

Reusable filter, data on stdin. For a true pipe (... | json-pretty, json-pretty < file.json) keep the program in a file and let stdin carry the data. Save this as, say, ~/.local/share/jennifer/json-pretty.j:

jennifer
use json;
use io;

def src as string init "";
while (not io.eof()) {
    $src = $src + io.readLine() + "\n";
}
io.printf("%s\n", json.encodePretty(json.decode($src)));
sh
alias json-pretty='jennifer run ~/.local/share/jennifer/json-pretty.j'

echo '{"b":2,"a":1}' | json-pretty
curl -s https://api.example.com/thing | json-pretty

The same shape extends to any decode / re-encode pair: swap json for xml (or yaml / toml) and the file becomes a pretty-xml.

Version injection

internal/version.Version holds the build version as a single string. The default is "dev"; the Makefile runs scripts/gen-version.sh before each build, which writes internal/version/version_gen.go containing a small init() that overwrites Version with the output of scripts/version.sh (a git describe --tags --long derivative; see ../libraries/meta.md for the format).

This codegen path replaces the more conventional go build -ldflags "-X .Version=..." because TinyGo before 0.43.0 silently ignores the -X directive (0.43.0 honours it, but 0.41.1 is still a supported, CI-tested toolchain). Codegen works identically on every toolchain. The generated file is .gitignored so the repository never carries a stale copy.

Two consumers read version.Version:

  • cmd/jennifer/main.go prints it in the help banner and as the body of the version subcommand.
  • internal/lib/meta/metalib.go mirrors it into the interpreter as the meta.VERSION constant. The meta library is opt-in like every other library: use meta; io.printf("%s\n", meta.VERSION);.

go test ./... skips codegen and uses the default "dev". The meta-lib test only checks that the constant matches version.Version, not a specific value, so it passes on any build.