| Crates.io | facet-args |
| lib.rs | facet-args |
| version | 0.29.0 |
| created_at | 2025-04-10 03:39:14.09265+00 |
| updated_at | 2025-09-17 18:24:50.719671+00 |
| description | Command-line argument parsing for the facet ecosystem |
| homepage | |
| repository | https://github.com/facet-rs/facet-args |
| max_upload_size | |
| id | 1627609 |
| size | 86,483 |
Provides CLI argument parsing (WIP).
use facet_pretty::FacetPretty;
use facet::Facet;
#[derive(Facet)]
struct Args {
#[facet(positional)]
path: String,
#[facet(named, short = 'v')]
verbose: bool,
#[facet(named, short = 'j')]
concurrency: usize,
}
# fn main() -> Result<(), Box<dyn std::error::Error>> {
let args: Args = facet_args::from_slice(&["--verbose", "-j", "14", "example.rs"])?;
eprintln!("args: {}", args.pretty());
Ok(())
# }
The behavior of facet-args is still in flux, but here are the broad strokes:
&'slice [&'text str]positional or named — fields lacking either annotation are ignoredshort = 'v' and short = "v" (where v can be any letter)positional args of type Vec (or anything that has a Def::List) will soak up all the positional
arguments — if followed by positional arguments of type String for example, those will never
get filledfacet(default) set: this includes Vec.Thanks to all individual sponsors:
...along with corporate sponsors:
...without whom this work could not exist.
The facet logo was drawn by Misiasart.
Licensed under either of:
at your option.