Skip to content

Instantly share code, notes, and snippets.

View andreimerlescu's full-sized avatar
:shipit:
Building Something Incredible…

Andrei Merlescu andreimerlescu

:shipit:
Building Something Incredible…
  • United States
  • 21:58 (UTC -04:00)
View GitHub Profile

The basics

#[arg()] decorates a field in a #[derive(Parser)] struct and tells clap how to parse that field from the command line. Every option inside #[arg()] is a key-value pair.


Naming

long — creates a --flag style argument. If you write #[arg(long)] with no value, it uses the field name. If you write #[arg(long = "1p")] it uses that string instead. That's why we have: