Use anyhow for ergonomic CLI errors.

Section: Common CLI crate recipes

Return `Result` from main

rust
rust
fn main() -> anyhow::Result<()> {
  println!("hello");
  Ok(())
}
Explanation

Returning `Result` from `main` is a clean pattern for CLI apps.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Common CLI crate recipes
Use clap derive for argument parsing
Derive a parser struct for a CLI.
OpenIn sheetrustsame section
Set log level through env
Enable application logging with `RUST_LOG`.
OpenIn sheetbashsame section
Add a crates.io dependency
Use a semantic version requirement.
Define package features
Declare named features in the manifest.
Minimal workspace root
Define workspace members from a root manifest.
Use a git dependency
Pin a crate directly from a Git repository.