boxlite). The CLI is implemented in the boxlite-cli crate and follows the same Rust Style Guide as the rest of the project.
Building the CLI
From the repository root:make runtime-debug, then runs cargo build -p boxlite-cli. The binary is produced at:
./target/debug/boxlite --help. For a release build, use:
./target/release/boxlite.
Testing
make test vs make test:cli
-
make testruns Rust library tests, Python SDK tests, and Node.js SDK tests. It does not run CLI tests. -
make test:cliruns the CLI integration tests. It depends onruntime-debugand then:
CLI tests are integration tests: they pull images, create boxes, and run real commands. They require a working VM environment (KVM on Linux or Hypervisor.framework on macOS). Tests use a shared test home (
/tmp/bl), a global lock to avoid concurrent use, and pre-pulled images (alpine:latest, python:alpine) to reduce rate limits.CLI test layout
- Entry points:
boxlite-cli/tests/*.rs— one file per command (e.g.run.rs,create.rs,exec.rs,list.rs). - Shared setup:
boxlite-cli/tests/common/mod.rsprovidesboxlite()returning aTestContextthat:- Uses
CARGO_BIN_EXE_boxliteand--homepointing at a shared directory (e.g./tmp/bl). - Uses a global lock so tests don’t run concurrently against the same home.
- Pre-pulls images, sets a timeout (e.g. 60s), and exposes
cleanup_box/cleanup_boxes.
- Uses
assert_cmd::Command and predicates to assert exit codes and stdout/stderr. New tests should use common::boxlite() and clean up any boxes they create (e.g. with --rm or ctx.cleanup_box(...)).
Example pattern:
Code structure
- Entry:
boxlite-cli/src/main.rs— parses the CLI and dispatches tocommands::*. - Subcommands and flags:
src/cli.rs— clap definitions:Cli,Commands,GlobalFlags,ProcessFlags,ResourceFlags,ManagementFlags. - Command implementations:
src/commands/*.rs— each command has anexecute(args, global); they shareglobal.create_runtime()and similar helpers.
Adding a new subcommand
Define the command
Add a new variant to
Commands in src/cli.rs and the corresponding Args type (or reuse existing flags).Command reference
| Command | Description |
|---|---|
make cli | Build the CLI (after building the debug runtime). |
make test:cli | Run CLI integration tests (single-threaded). |
make test | Run Rust, Python, and Node unit tests (no CLI tests). |
make fmt | Format all Rust code. |
cargo clippy -p boxlite-cli | Lint the CLI crate. |
See also
- Rust Style Guide — coding standards for BoxLite.
- CONTRIBUTING.md — general contribution workflow.
- boxlite-cli README — user-facing CLI documentation.