1 unstable release

0.1.0-beta.5 Oct 13, 2021
0.1.0-beta.1 Oct 12, 2021

#42 in #args


Used in rust2uml

MIT/Apache

35KB
694 lines

argi

Argument parsing for the future 🚀

Features

  • Macro-based approach, providing an intuitive way to layout a cli
  • Rich auto-help generation, styling based off of python's click library
  • Zero dependencies
  • Speedy compile times
  • Low binary bloat

This library is intended to be a replacement for both heavier structopt/clap-based interfaces due to amount of features contained within, as well as slim ones based upon pico-args due to the small workflow and compilation footprint. As this crate isn't fully battle-tested yet, smaller programs are a prime contender for usage with this library.

Usage

Place the following into your Cargo.toml file:

[dependencies]
argi = "0.1.0-beta.5"

Example

Complete demo (help page):

use argi::{cli, data};

fn main() {
    cli!(
        help: "Imaginary webapp program, allowing simple tasks",
        launch: {
            help: "Launches instance to given address",
            run: (|ctx, _| todo!("Launch at port {:?}", data!(ctx => --port))),
            --db [url]: { help: "Database URL" },
            --bind [url]: { help: "Binding address" },
            --port [port]: { help: "Port to hook onto" },
        },
        delete [int?]: {
            help: "Deletes an optional id from the database",
            run: (|_, data| todo!("Delete {:?}", data))
        }
    )
    .launch();
}

You can find more of the examples shown below within the useful examples/ directory!

Licensing

This project is dual-licensed under both MIT and Apache, so feel free to use either at your discretion. Links to the files are listed below:

No runtime deps