
Exit Codes and Error Output for Rust Command Line Tools
Exit codes are how scripts know your tool failed. Return 0 for success, a nonzero code for failure, send errors to stderr, and let main return ExitCode or Result.
Everything you need to level up your coding skills.

Exit codes are how scripts know your tool failed. Return 0 for success, a nonzero code for failure, send errors to stderr, and let main return ExitCode or Result.

Read stdin as lines, bytes or all at once, handle empty input, detect pipes versus terminals, and avoid loading huge streams into memory.

Show progress for long operations with indicatif: bars with known length, spinners for unknown work, wrapping iterators and keeping log lines from garbling the bar.

Add colors to CLI output with anstyle or owo-colors, and turn them off when stdout is not a terminal or NO_COLOR is set, so pipes and logs stay clean.

Build a git hook manager in Rust: read a hooks config, install shims into .git/hooks, run commands on staged files in order, and report results with proper exit codes.

Build a todo list CLI in Rust with clap subcommands, serde JSON storage, stable ids, atomic and durable saves, and a file lock that stops concurrent runs from losing items. Every claim measured.

Build a Markdown link checker in Rust: extract links with pulldown-cmark, check them concurrently with reqwest and a semaphore, retry, report and set exit codes.

Build a fast file finder in Rust: parallel directory walking with the ignore crate, glob and regex filters, size and type predicates, and sorted deterministic output.

Build a grep clone in Rust from a naive version that panics on Latin-1 text to a streaming one that searches 72 MB in 77 ms with 2.5 MB of memory, handling binary files, exit codes and broken pipes.

Know whether stdout is a terminal or a pipe, and change behavior: color, progress bars, paging, width and line buffering. Use IsTerminal and NO_COLOR correctly.

Build a terminal user interface with Ratatui: init and restore, the draw loop, widgets and layout, handling key events and state, with a small counter and list app.

Load settings from environment variables into a typed struct at startup, fail fast on missing values, give safe defaults for the rest and keep secrets out of logs and Debug output.
We send one email when a new post is published. No spam.