CLI Reference
The draft CLI is the primary tool for working with Draft projects.
Commands
Section titled “Commands”draft new
Section titled “draft new”Create a new Draft project:
draft new <name> [options]Options:
--template <name>— Project template (default, web, embedded, mobile, game)--path <path>— Directory to create project in
draft new my-appdraft new my-app --template webdraft new my-app --template embeddeddraft build
Section titled “draft build”Compile a Draft project:
draft build [options]Options:
--target <target>— Compilation target (native, wasm, wasi)--release— Release build (optimized)--debug— Debug build--output <path>— Output path--lib— Build as library--minify— Minify output--compress— Compress output--source-map— Generate source map
draft builddraft build --releasedraft build --target wasmdraft build --target wasm --minifydraft build --output my-appdraft run
Section titled “draft run”Compile and run a Draft program:
draft run <file> [options]Options:
--target <target>— Runtime target--release— Release build--args <args>— Arguments to pass to program
draft run main.draftdraft run main.draft --releasedraft run main.draft --args "arg1 arg2"draft test
Section titled “draft test”Run tests:
draft test [options]Options:
--target <target>— Test target--filter <pattern>— Filter tests by name--release— Release build--watch— Watch for changes and re-run
draft testdraft test --filter "test_add"draft test --watchdraft fmt
Section titled “draft fmt”Format Draft source files:
draft fmt [options] [files]Options:
--check— Check formatting without changes--diff— Show formatting diff
draft fmtdraft fmt src/draft fmt --checkdraft fmt main.draftdraft check
Section titled “draft check”Check code for errors without compiling:
draft check [options]Options:
--warnings— Show warnings
draft checkdraft check --warningsdraft clean
Section titled “draft clean”Remove build artifacts:
draft cleandraft doc
Section titled “draft doc”Generate documentation:
draft doc [options]Options:
--output <path>— Output directory--open— Open docs in browser
draft docdraft doc --output docs/draft doc --opendraft deps
Section titled “draft deps”Manage dependencies:
draft deps <command>Commands:
install— Install dependenciesupdate— Update dependencieslist— List dependenciessearch <query>— Search for packages
draft deps installdraft deps updatedraft deps listdraft deps search httpdraft add
Section titled “draft add”Add a dependency:
draft add <package> [version]draft add httpdraft add http 1.2.0draft add json --features serdedraft remove
Section titled “draft remove”Remove a dependency:
draft remove <package>draft publish
Section titled “draft publish”Publish a package:
draft publish [options]Options:
--dry-run— Simulate publish--registry <url>— Registry URL
draft package
Section titled “draft package”Create a package:
draft package [options]draft init
Section titled “draft init”Initialize a new package in current directory:
draft init [options]draft target
Section titled “draft target”Manage compilation targets:
draft target <command>Commands:
list— List installed targetsadd <target>— Add a targetremove <target>— Remove a targetavailable— List available targets
draft target listdraft target add wasmdraft target add arm-none-eabidraft target availabledraft run
Section titled “draft run”Run a compiled program:
draft run <binary>draft flash
Section titled “draft flash”Flash to embedded device:
draft flash [options]Options:
--target <target>— Target platform--probe <probe>— Debug probe
draft flashdraft flash --target thumbv7em-none-eabihfdraft debug
Section titled “draft debug”Start debugging session:
draft debug [options]Options:
--gdb— Use GDB--lldb— Use LLDB--swo— Enable SWO trace
draft debugdraft debug --gdbdraft deploy
Section titled “draft deploy”Deploy application:
draft deploy [options]Options:
--target <target>— Deployment target
draft deploydraft deploy --target webdraft deploy --target iosdraft upgrade
Section titled “draft upgrade”Upgrade Draft installation:
draft upgradedraft version
Section titled “draft version”Print version information:
draft versiondraft --versiondraft -Vdraft help
Section titled “draft help”Show help:
draft helpdraft help <command>draft --helpdraft -hdraft completion
Section titled “draft completion”Generate shell completions:
draft completion <shell>Supported shells: bash, zsh, fish, powershell, elvish
draft completion bash > /etc/bash_completion.d/draftGlobal Options
Section titled “Global Options”--verbose/-v— Verbose output--quiet/-q— Quiet output--color <when>— Color output (auto, always, never)--config <path>— Config file path
Configuration
Section titled “Configuration”draft.toml
Section titled “draft.toml”[package]name = "my-app"version = "0.1.0"edition = "2024"authors = ["Your Name <you@example.com>"]description = "My Draft application"license = "MIT"
[dependencies]http = "1.2.0"json = { version = "1.0", features = ["serde"] }
[profile.release]opt-level = 3lto = trueEnvironment Variables
Section titled “Environment Variables”| Variable | Description |
|---|---|
DRAFT_HOME |
Draft installation directory |
DRAFT_TARGET |
Default compilation target |
DRAFT_LOG |
Log level |
DRAFT_REGISTRY |
Package registry URL |
Exit Codes
Section titled “Exit Codes”| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | General error |
| 2 | Compilation error |
| 3 | Runtime error |
| 4 | Configuration error |
| 5 | I/O error |
