5 unstable releases

0.3.0 Dec 27, 2023
0.2.0 Sep 21, 2023
0.1.4 Jul 9, 2023
0.1.1 Jun 25, 2023
0.1.0 Jun 25, 2023

#241 in Command-line interface

Download history 14/week @ 2023-12-18 59/week @ 2023-12-25 15/week @ 2024-01-08 3/week @ 2024-01-15 3/week @ 2024-02-05 14/week @ 2024-02-12 69/week @ 2024-02-19 54/week @ 2024-02-26 23/week @ 2024-03-04 31/week @ 2024-03-11 24/week @ 2024-03-18 59/week @ 2024-03-25 62/week @ 2024-04-01

183 downloads per month
Used in 15 crates (14 directly)

Apache-2.0

9KB
117 lines

arrrg

arrrg provides an opinionated [CommandLine] parser.

For example, let's consider the parser specified here using the derive syntax:

use arrrg_derive::CommandLine;

#[derive(CommandLine, Debug, Default, Eq, PartialEq)]
struct Options {
    #[arrrg(optional, "this is the help text", "PLACEHOLDER")]
    some_string: String,
    #[arrrg(nested)]
    some_prefix: SomeOptions,
}

#[derive(CommandLine, Debug, Default, Eq, PartialEq)]
struct SomeOptions {
    #[arrrg(required, "this is the help text", "PLACEHOLDER")]
    a: String,
    #[arrrg(optional, "this is the help text", "PLACEHOLDER")]
    b: String,
}

This will provide the options to getopts of --some-string, --some-prefix-a, --some-prefix-b. In general the rule is to derive the flag names from the identifiers of struct members. When nesting the name will be the concatenation of the prefix from the parent struct and the member identifier from the child struct. Unlimited nesting is possible. Underscores change to dashes.

This library takes an opinionated stance on the command line. There should be exactly one canonical argument order on the command-line and all applications must be built with this in mind. Users of the library can call CommandLine::from_command_line_relaxed to disable this checking.

Status

Maintenance track. The library is considered stable and will be put into maintenance mode if unchanged for one year.

Scope

arrrg will provide the CommandLine trait and wrapper around getopts.

Warts

  • Nested derive parameter names can get unwieldy.

Documentation

The latest documentation is always available at docs.rs.

Dependencies

~1.5MB
~36K SLoC