#parser

auto-args

Parse command line arguments by defining a struct

12 releases

0.3.1 Jul 27, 2024
0.3.0 Nov 28, 2023
0.2.9 Jul 9, 2021
0.2.7 Jun 11, 2020
0.1.0 Jul 29, 2019

#371 in Command-line interface

Download history 6/week @ 2024-06-15 6/week @ 2024-06-22 1/week @ 2024-06-29 88/week @ 2024-07-06 37/week @ 2024-07-13 183/week @ 2024-07-20 443/week @ 2024-07-27 8/week @ 2024-08-03 749/week @ 2024-08-10 185/week @ 2024-08-17 224/week @ 2024-08-24 1174/week @ 2024-08-31 18/week @ 2024-09-07 402/week @ 2024-09-14 200/week @ 2024-09-21 1034/week @ 2024-09-28

1,665 downloads per month
Used in 2 crates

Apache-2.0/MIT

41KB
703 lines

AutoArgs Build Status

Parse command line arguments by defining a struct. It uses a derive to define a set of command-line flags. It does not use clap and its dependencies are rather slimmer.

The basic idea is that you define a type that represents the information you want on the command-line from the person running your program, and derive(AutoArgs) on that type, and then call YourType::from_args() to find out what your user gave you.

Differences from ClapMe

AutoArgs is essentially equivalent to ClapMe. It only differs in implementation, speed of compilation, help messages, and error messages.

Differences from structopt

StructOpt is a tool that serves the same function as auto-args, but with a different philosophy. StructOpt strives to be as expressive as clap, and to enable all features clap does, and with a tightly coupled API. It does this by extensive use of attributes such as #[structopt(long = "long-name")], which define the behavior and property of each flag. This makes it powerful, but also rather verbose to use.

In contrast, AutoArgs does not (yet?) support any attributes, and determines all behavior directly from your type. This means that you don't repeat yourself, but also means that you have less fine-grained control over your interface, and some interfaces may be well-nigh impossible.

You can implement the AutoArgs trait manually, which does make it possible (and not even that painful) to create a different command-line for a given type, but this is not the intended way to use AutoArgs.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~2MB
~49K SLoC