parkour
A fast, extensible, command-line arguments parser.
Introduction ๐
The most popular argument parser, clap, allows you list all the possible arguments and their constraints, and then gives you a dynamic, stringly-typed object containing all the values. Usually these values are then manually extracted into structs and enums to access the values more conveniently and get the advantages of a static type system (example).
Parkour uses a different approach: Instead of parsing the arguments into an intermediate, stringly-typed object, it parses them directly into the types you want, so there's no cumbersome conversion. For types outside the standard library, you need to implement a trait, but in most cases this can be done with a simple derive macro.
This has several advantages:
- It is very flexible: Every aspect of argument parsing can be tailored to your needs.
- It is strongly typed: Many errors can be caught at compile time, so you waste less time debugging.
- It is zero-cost: If you don't need a feature, you don't have to use it. Parkour should also be pretty fast, but don't take my word for it, benchmark it ๐
Status
Parkour started as an experiment and is very new (about 1 week old at the time of writing). Expect frequent breaking changes. If you like what you see, consider supporting this work by
- Reading the docs
- Trying it out
- Giving feedback in this issue
- Opening issues or sending PRs
Right now, parkour lacks some important features, which I intend to implement:
- Auto-generated help messages
- A DSL to write (sub)commands more ergonomically
- More powerful derive macros
- Error messages with ANSI colors
Example
use *;
Code of Conduct ๐ค
Please be friendly and respectful to others. This should be a place where everyone can feel safe, therefore I intend to enforce the Rust code of conduct.
License
This project is licensed under either of
- Apache License, Version 2.0, ([LICENSE-APACHE] or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license ([LICENSE-MIT] or https://opensource.org/licenses/MIT)
at your option.