Crates.io | arrrg |
lib.rs | arrrg |
version | 0.6.0 |
source | src |
created_at | 2023-06-25 04:38:34.555773 |
updated_at | 2024-12-04 14:10:17.202528 |
description | arrrg provides a wrapper around the getops library for stable commandline parsing. |
homepage | |
repository | https://github.com/rescrv/blue |
max_upload_size | |
id | 899299 |
size | 13,922 |
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.
Maintenance track. The library is considered stable and will be put into maintenance mode if unchanged for one year.
arrrg will provide the CommandLine trait and wrapper around getopts.
The latest documentation is always available at docs.rs.