Skip to content

Building a CLI

Vow CLIs are ordinary native binaries. Grant only the env keys (or paths) the tool should see.

From tests/lang/cli_util.vow:

fn main(caps: Caps) -> int {
return match caps.env {
Some(cap) => match env_get(cap, "HOME") {
Ok(s) => len(s),
Err(_) => 0 - 1
},
None => 0 - 1
};
}
Terminal window
vow build tests/lang/cli_util.vow -o cli_util
./cli_util --grant env:HOME
echo $? # length of HOME, or an error code path

Without --grant env:HOME, caps.env is None and the program cannot call env_get.

  • Exit codes are how many examples communicate results — keep them intentional.
  • Prefer vow check / vow check --json in CI before vow build.
  • print is fine for developer output; it does not require a grant (ambient by design).
  • Scaffold with vpm init when you want project.toml + deps.