larpa

Crates.iolarpa
lib.rslarpa
version0.1.1
created_at2025-11-19 14:56:51.595159+00
updated_at2025-11-20 11:06:01.83633+00
descriptionLousy ARgument PArser
homepage
repositoryhttps://github.com/SludgePhD/Larpa
max_upload_size
id1940209
size175,368
Sludge (SludgePhD)

documentation

https://docs.rs/larpa

README

Larpa: The Lousy Argument Parser.

A simple #[derive]-based command line argument parsing library.

Goals

  • Stay more lightweight than Clap, while providing many of its bells and whistles in an easier-to-digest package with a simpler API.
  • Provide built-in generation of --help/--version output.
  • Build a well-designed, stable, intuitive API surface that I can proudly publish as 1.0.0.

Non-Goals

  • Handle all possible command-line interfaces.
    • Larpa aims to handle all reasonable command-line interfaces that roughly adhere to the GNU CLI argument conventions, but not more than that.
    • In particular, order-dependent named arguments or argument groups will probably never be supported, as the #[derive]-based design isn't a good fit. Use something like lexopt instead.
    • Dynamically constructing and modifying the accepted syntax of the command-line interface will also likely never be supported. Use Clap instead.
  • Handle weird/niche use cases like #![no_std] usage, or operating systems that are significantly different from Unix or Windows.

Example

use larpa::Command;
use larpa::types::Verbosity;
use std::path::PathBuf;

#[derive(Command)]
struct Shredder {
    /// Output more information.
    #[larpa(name = ["-v", "--verbose"], flag)]
    verbosity: Verbosity,

    /// Output less information.
    #[larpa(name = ["-q", "--quiet"], flag, inverse_of = "verbosity")]
    quiet: (),

    /// The configuration file to use.
    #[larpa(name = "--config")]
    config: Option<PathBuf>,

    /// The speed to run the shredder at (in RPM).
    #[larpa(name = ["-s", "--speed"], default = "8000.0")]
    speed: f64,

    /// Path to the file to shred (or `-` to shred data from stdin).
    file: PathBuf,
}

Rust Version Support

This library targets the latest Rust version.

Older Rust versions are supported by equally older versions of this crate. For example, to use a version of Rust that was succeeded 6 months ago, you'd also use an at least 6 month old version of this library.

Compatibility with older Rust versions may be provided on a best-effort basis.

The minimum supported Rust version is specified as rust-version in Cargo.toml, and tested against in CI, so Cargo's resolver should find a version for you that works.

Commit count: 0

cargo fmt