Skip to content
Select theme

Build a CLI tool in Rust

What you end up with: hit, a command-line HTTP client you would actually use — subcommands, request headers and bodies, a config file, coloured and JSON output, and a release build you can hand to someone else.

The finished tool answering a slow request: a coloured status line, a header table, and the JSON body httpbin echoes back

Command-line tools are where most people write their first real Rust, and for good reason: no async runtime to fight with at the start, no framework abstractions, and the feedback loop is a single cargo run. By the end of the track you will have used half the crates that show up in every Rust CLI: clap, reqwest, serde, anyhow, indicatif.

  • hit get https://example.com — send a request, print a readable response
  • Subcommands (get, post, header) modelled as Rust enums
  • --json output for piping into jq
  • A ~/.config/hit/config.toml file with environment-variable overrides
  • Tests: unit tests, integration tests, and snapshot tests for output
  • A signed, cross-compiled release binary and a Homebrew formula

You need Rust installed (rustup.rs if it is not) and a rough idea of what ownership does. If either is shaky, start here:

No async experience required — the track introduces it where it is actually needed.

cli-tool/ in the examples repository — each article links to the tag that matches its finished state.