Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Command line

The binary is lt. Paths may be files or directories; a directory is searched recursively for *.lt.

lt init [dir] [--name <pkg>] [--force]  create a package (cwd by default)
lt check [--offline] <path>...          resolve imports and type check
lt fmt [--check] <path>                 format in place, or check formatting
lt ast <path>                           dump the AST (debugging)
lt build -t ts|py|go [--offline] <entry>    compile a package
lt test  -t ts|py|go [--offline] <entry>... emit and optionally run tests
lt ir <entry>                           dump the typed IR (debugging)
lt add <key> --git <url> --version <req> [--root <dir>]
lt add <key> --path <dir> [--root <dir>]
lt remove <key>                         remove a dependency
lt update <key>|--all                   re-resolve dependencies, rewrite lt.lock
lt vendor [--offline]                   copy locked sources into vendor/
lt migrate [--write]                    migrate v2 imports to v3
lt lsp                                  LSP server over stdio
lt playground                           generate the static example gallery

lt init

lt init                 # current directory
lt init money           # ./money
lt init money --name billing
lt init money --force

Creates lt.toml, src/<package>.lt, and .gitignore with /out. The package name is derived from the directory and normalized to lowercase_snake_case; --name overrides it. Existing files are not overwritten unless --force is given.

lt check

lt check src/
lt check --offline src/

Resolves the import graph and type-checks every entry. Diagnostics are printed with a source snippet. Exit code is 1 when any file fails and 0 otherwise. --offline forbids network access; an incomplete lt.lock is an error.

lt fmt

lt fmt src/
lt fmt --check src/

lt fmt rewrites files in the canonical form. lt fmt --check prints the files that differ and exits 1 without writing. Formatting is idempotent.

lt build

lt build -t ts src/money.lt
lt build -t py src/money.lt --out out
lt build -t go src/money.lt --offline
FlagDefaultMeaning
-t, --targettsts, py, or go
--outoutoutput root; the target name is appended
--offlineoffforbid network access

build writes the library package only. Test declarations stay out of the output. It never writes lt.lock.

lt test

lt test -t ts tests/*.lt --out out/conf --run
FlagDefaultMeaning
-t, --targettsts, py, or go
--outoutoutput root; the target name is appended
--runoffrun vitest, pytest, or go test
--usageoffalso emit a runnable calling example per package
--offlineoffforbid network access

Without --run, the generated files are written and the command prints the native command to run. --usage is used by the documentation gallery.

Dependencies

lt add foo --git https://github.com/foo/bar --version "^1.2"
lt add foo --git https://github.com/foo/bar --version "^1.2" --root packages/foo
lt add utils --path ../utils
lt remove foo
lt update foo
lt update --all
lt vendor
lt vendor --offline
  • add writes the dependency to lt.toml. --root selects a subdirectory inside the checkout.
  • remove deletes it from lt.toml and lt.lock.
  • update resolves versions and rewrites lt.lock; --all walks the whole graph.
  • vendor copies locked sources into vendor/ for offline builds.

See Packages and dependencies and import v3.

lt migrate

lt migrate          # report v2 imports that need rewriting
lt migrate --write  # rewrite them in place

lt ast and lt ir

lt ast src/money.lt
lt ir src/money.lt

Both print a Rust debug representation to stdout. They are debugging aids, not a stable format.

lt lsp

lt lsp

An LSP server over stdio: diagnostics, hover, definition, references, completion, signature help, symbols, highlights, formatting, rename, and import quick fixes.

lt playground

lt playground
lt playground --root playground --out out/playground
lt playground --allow-stale

Generates the static gallery at out/playground/index.html. --allow-stale permits generation when evidence.json does not match the current cases.

Exit codes

CodeMeaning
0success
1compilation, formatting, dependency, or test failure
2invalid command line