| Crates.io | jaarg |
| lib.rs | jaarg |
| version | 0.2.2 |
| created_at | 2025-11-02 08:53:03.486222+00 |
| updated_at | 2025-11-26 04:33:30.777967+00 |
| description | It can parse your arguments you should use it it's called jaarg |
| homepage | https://gay.pizza/ |
| repository | https://github.com/gay-pizza/jaarg |
| max_upload_size | |
| id | 1912877 |
| size | 76,395 |
Dependency-free, const (mostly), no magic macros, no_std & no alloc (though nicer with those).
Some say it can parse your arguments.
// Variables for arguments to fill
let mut file = PathBuf::new();
let mut out: Option<PathBuf> = None;
let mut number = 0;
// Set up arguments table
enum Arg { Help, Number, File, Out }
const OPTIONS: Opts<Arg> = Opts::new(&[
Opt::help_flag(Arg::Help, &["-h", "--help"]).help_text("Show this help and exit."),
Opt::value(Arg::Number, &["-n", "--number"], "value")
.help_text("Optionally specify a number (default: 0)"),
Opt::positional(Arg::File, "file").required()
.help_text("Input file."),
Opt::positional(Arg::Out, "out")
.help_text("Output destination (optional).")
]).with_description("My simple utility.");
// Parse command-line arguments from `std::env::args()`
match OPTIONS.parse_easy(|program_name, id, _opt, _name, arg| {
match id {
Arg::Help => {
OPTIONS.print_full_help(program_name);
return Ok(ParseControl::Quit);
}
Arg::Number => { number = str::parse(arg)?; }
Arg::File => { file = arg.into(); }
Arg::Out => { out = Some(arg.into()); }
}
Ok(ParseControl::Continue)
}) {
ParseResult::ContinueSuccess => (),
ParseResult::ExitSuccess => std::process::exit(0),
ParseResult::ExitError => std::process::exit(1),
}
// Print the result variables
println!("{file:?} -> {out:?} (number: {number:?})",
out = out.unwrap_or(file.with_extension("out")));
v0.2.2:
ArgumentError not being rewritten for positional arguments.pub use.v0.2.1:
Cargo.toml.v0.2.0:
MIT to MIT OR Apache-2.0.Opts::parse_map into newly introduced alloc crate, making it accessible for no_std users.StandardErrorUsageWriter,
generalised "Usage" line in standard full writer, enough public constructs to roll a custom help writer.no_std examples.v0.1.1:
v0.1.0:
Near future:
Long term:
jaarg is dual-licensed under either the MIT or Apache 2.0 licences. Pick whichever works best for your project.