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


title: "Extending the CLI (Rust)" weight: 80 summary: "The CLI is implemented in Rust with clap. Add or change subcommands in crates/sruja-cli." tags: ["cli", "rust", "advanced"]

Extending the CLI (Rust)

Sruja's CLI lives in crates/sruja-cli and uses clap for argument parsing. To add or change subcommands:

  1. Open crates/sruja-cli/src/main.rs (or the relevant module) and see how existing commands (e.g. lint, export) are defined.
  2. Add a subcommand using clap's Subcommand enum and match on it in the main entrypoint; run your logic and return Result with ? for errors.
  3. Run and test with cargo run -p sruja-cli -- <subcommand> ....

Shell completions are available:

sruja completion bash
sruja completion zsh
sruja completion fish

For patterns and conventions, see the repo's AGENTS.md (Rust skills) and docs/CODING_GUIDELINES.md.