Skip to content

Embedded CLI

The wabe-disk CLI opens storage directly in its own process. Use HTTP to interact with an already-running server. Avoid opening a second writer against the server’s active storage prefix.

Run with the server stopped
printf 'Hello wabe Disk\n' | ./target/release/wabe-disk --data ./.data put demo /hello.txt
./target/release/wabe-disk --data ./.data get demo /hello.txt

Subcommands put DISK PATH and get DISK PATH use local stdin and stdout. They do not accept an HTTP URL.

Terminal window
./target/release/wabe-disk --data ./.data exec demo 'cat /hello.txt'
./target/release/wabe-disk --data ./.data exec demo --branch main 'git add /hello.txt; git commit -m greeting'
./target/release/wabe-disk --data ./.data exec demo --kind js 'print(await fs.readFile("/hello.txt", "utf8"))'

Omitting the script argument reads source from stdin:

Terminal window
./target/release/wabe-disk --data ./.data exec demo <<'WABE'
mkdir -p /notes
printf 'hello\n' > /notes/hello.txt
cat /notes/hello.txt
WABE

When source is an argument, stdin remains available for data:

Terminal window
printf '{"enabled":true}' |
./target/release/wabe-disk --data ./.data exec demo 'kv put app feature --json; kv get app feature'

JavaScript requires Linux. CLI JS execution exposes stdout/stderr and success/failure; a returned JS value is not printed automatically. Use print to produce CLI output.

exec --branch NAME selects the branch for file operations and Git commands together. Bash containing Git requires this option or git --branch NAME on each Git command. Branch selection is local to the execution.

Run wabesql inside exec to create a named database and query it:

Terminal window
./target/release/wabe-disk --data ./.data exec demo 'wabesql database create app'
./target/release/wabe-disk --data ./.data exec demo "wabesql query app 'SELECT 1;'"

wabesql query app < /migrations/001.sql reads a file from the virtual disk. To supply a host file instead, pass the shell source as an argument and redirect the host command’s stdin: wabe-disk exec demo 'wabesql query app' < ./001.sql. Query output is NDJSON. CLI queries require an existing database; HTTP SQL connections create missing databases automatically. See SQL commands for transactions, errors and value encoding.

Terminal window
./target/release/wabe-disk --data ./.data chunk-size demo 65536
./target/release/wabe-disk --data ./.data gc demo

Each CLI run closes its managed disks and confirms pending writes before exiting, including after a script error when closing succeeds. There are no top-level CLI volume, flush or evict subcommands in this version. The HTTP server exposes separate flush and eviction routes.