Skip to content

Playbooks for g

Story-style workflows—solo, team, and on-call. Jump into the full Use cases page anytime.

crate root (g)

Program entry point and top-level command routing.

auto-generated This page is built from //! comments in the Rust source. Edit the source and run npm run docs:extract to update it.

Program entry point and top-level command routing.

Tutorial overview

  • main is the required entry point for a Rust binary crate.
  • We delegate to [run] so we can return a Result and use ? for ergonomic error propagation.
  • The CLI is parsed via clap derive macros into typed enums/structs.
  • We then dispatch to feature modules (commands::*) using match.

Rust concepts used here

  • Result<T, E> and the ? operator for error propagation.
  • Pattern matching (match, if let, while let) to unpack enums/Options.
  • Trait objects (&dyn Error) for printing a chain of errors.
  • Borrowing and references (&name, &args) to avoid cloning.

Source: src/main.rs