Clap Argument Validation Not every argument can be trusted simply because it parses into the right type. A string might convert fine into a PathBuf or a number, while still being meaningless in context, such as a percentage over 100 or a pa...
Clap Subcommands Many command line tools split their functionality into subcommands. Familiar tool commands include git commit and cargo build, where the first word selects a specific action with its own set of arguments. Clap supports this...
Clap Derive Parser Macro Clap's Parser derive macro is the most common way to define a command line interface in Rust. Instead of manually parsing std::env::args(), you describe the shape of your arguments as a struct, and Clap generates al...
Decode audio samples from a file [![symphonia-badge]][symphonia] [![cat-multimedia-badge]][cat-multimedia] Measuring a clip's length or feeding it to an analyzer means decoding its samples, whatever the container. [symphonia][symphonia] pro...
Resize and re-encode an image [![image-badge]][image] [![cat-multimedia-badge]][cat-multimedia] Serving a small preview of a large upload means decoding the original, shrinking it, and writing it back in a web-friendly format. image::open r...
Multimedia | Recipe | Crates | Categories | |--------|--------|------------| | Resize and re-encode an image | [![image-badge]][image] | [![cat-multimedia-badge]][cat-multimedia] | | Detect an image format from its bytes | [![image-badge]][...
Reload configuration when the file changes [![config-badge]][config] [![notify-badge]][notify] [![cat-config-badge]][cat-config] [![cat-filesystem-badge]][cat-filesystem] A long-running service can pick up edits to its config file without a...
Store per-user configuration with confy [![confy-badge]][confy] [![cat-config-badge]][cat-config] A desktop or CLI program that remembers a user's preferences should write them to the platform's standard config location, not next to the bin...
Merge multiple providers with figment [![figment-badge]][figment] [![cat-config-badge]][cat-config] [figment][figment] assembles configuration from independent providers. A provider can be a TOML, JSON, or YAML file, or a set of environment...
Layer defaults, a file, and environment variables [![config-badge]][config] [![cat-config-badge]][cat-config] Most applications resolve their configuration from several places: defaults that ship with the binary, a config file an operator e...
Configuration | Recipe | Crates | Categories | |--------|--------|------------| | Layer defaults, a file, and environment variables | [![config-badge]][config] | [![cat-config-badge]][cat-config] | | Merge multiple providers with figment |...
Find an Executable Find a binary on the PATH [![which-badge]][which] [![cat-filesystem-badge]][cat-filesystem] Locating an executable means walking each directory on the PATH. It also means applying the platform's rules. On Windows that inc...
Read CSV data with a parsing expression grammar [![pest-badge]][pest] [![cat-parser-implementations-badge]][cat-parser-implementations] [pest][pest] takes a different approach from the combinator libraries: instead of writing parser code, y...
Parse an unstructured string into key value pairs [![winnow-badge]][winnow] [![cat-parser-implementations-badge]][cat-parser-implementations] [winnow][winnow] is a parser-combinator library descended from nom, tuned for ergonomics and speed...
Parsing content from string
Parsing | Recipe | Crates | Categories | |--------|--------|------------| | Parse tagged fields from a log line | [![nom-badge]][nom] | [![cat-parser-implementations-badge]][cat-parser-implementations] | | Decode a hex color | [![nom-badge]...
Option and Result Combinators