Keyboard shortcuts

Press or to navigate between chapters

Press ? to show this help

Press Esc to hide this help

Getting Started

Prerequisites

Install the Rust toolchain and cargo-generate:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
cargo install cargo-generate

Create a Project

cargo generate rararulab/cli-template

You’ll be prompted for three values:

PlaceholderFormatExampleUsed For
project-namekebab-casemy-awesome-cliBinary name, directory, npm pkg
crate_namesnake_case(auto-derived)Rust module name
github-orgmyorgRepo URLs, CI badges

crate_name is derived automatically from project-name — you rarely need to change it.

First Run

cd my-awesome-cli
cargo check
cargo test
cargo run -- --help
cargo run -- hello world

The hello command is a working example wired end-to-end. Use it as a reference when adding your own commands.

What to Customize

Once you’ve verified the template builds, update these files:

  • CLAUDE.md — add a description of your project for AI-assisted development
  • Cargo.toml — set description, repository, and homepage
  • src/cli/mod.rs — replace the example Hello command with your own
  • src/app_config.rs — replace ExampleConfig with your app’s config fields
  • README.md — rewrite for your project

Clean Up Example Code

Once your first real command is in place, remove the scaffolding:

  1. Delete the Hello variant from the Command enum in src/cli/mod.rs
  2. Delete its match arm in main.rs
  3. Replace ExampleConfig in src/app_config.rs with your own config struct

Don’t delete the example code until you have a real command working. It serves as a reference for the patterns used throughout the template.

Verify

cargo check && cargo test && cargo clippy

All three should pass cleanly before your first commit.

Next Steps