pound
a low footprint, derive-first cli parser for rust. the derive emits a flat &'static
description of your command line and a single non-generic engine interprets it,
so derive ergonomics stay familiar while adding almost nothing to your binary
and dragging in nothing at runtime.
status
working: tokenizer (long, short, -abc bundling, --opt=val, --),
subcommands (top-level, as a struct field, and nested), mutually-exclusive
groups (optional or required), pairwise conflicts, counts, defaults, hidden
args/commands, gnu-style help, auto help/version, and a FromArg trait for
custom value types, all behind the #[derive(Parse)] / #[derive(ValueEnum)]
macros. you can also hand-build a CommandSpec and impl Parse, see
pound/tests/cli.rs.
model
field shapes carry meaning, so most fields need no attribute:
| shape | meaning |
|---|---|
bool |
flag, presence is true |
T |
required positional |
Option<T> |
optional positional |
Vec<T> |
variadic / repeatable |
#[pound(short)] / #[pound(long)] promote any of these to a named option. the
annotated thing is the switch, values stay bare.
field attributes: short, long (bare or = "name" / = 'c'), positional,
trailing (everything after --), count (-vvv into a uN), default =,
value_name =, help =, group = "name" (mutually exclusive set),
conflicts_with = "field", hidden (omit from help), and subcommand (the
field's type, itself a Parse enum, supplies the commands; Option<T> makes the
subcommand optional). item attributes: name =, version =,
required_group = "name" (exactly one of the group must be set), and hidden on
an enum variant to hide that command. an enum derives a subcommand tree, one
variant per command. #[derive(ValueEnum)] makes a unit enum a FromArg choice
type with kebab-cased values, and its choices are listed automatically in help
and in invalid-value errors.
use Parse;
let add = parse; // exits on -h/--help or a parse error
a struct can carry global options and delegate the rest to a subcommand enum:
custom value types implement FromArg:
use ;
;
features
help(default): bake doc-comment help into the binary and enable the formatter. build withdefault-features = falsefor the leanest binary, help degrades to a one-line usage string.
dev
the dev environment is a nix flake. nix develop gives the toolchain,
nix develop .#fmt formats the tree (nightly rustfmt + taplo) on entry.
license
EUPL-1.2