This lib builds on top of clap
and auto-propagates Cargo.toml
infos (name, version, author, repo) into the application using it.
Running app --help
now automatically includes this information in its output.
Cargo.toml
is the single source of truth containing application attributes such as:
* name
* version
* author(s)
* description
This information is usually duplicated in the app's main
, leading to potential inconsistencies (update in one place but not another).
Moreover, a crate unifying this would provide consistency across all apps using it.
Finally, code for app initialization is minimal.
```rust use clap::{App, Arg}; use autoclap::autoclap;
fn main() { let app = autoclap!(); // return a clap::App app.arg( Arg::withname("myarg") .long("myarg") .short('m') .help("My arg description."), ) .getmatchessafe() .unwrapor_else(|e| e.exit()); } ```
Now, running app --help
now produces:
app 0.1.0 :: https://github.com/username/app/releases/tag/0.1.0
Crate Author <crateauthor@e.mail>
🧵 The crate awesome description.
The packge repository URL is concatenated with the version of a package to form a URL to a specific release.
This URL goes live when a release with the same version as the crate is published.
autoclap
offers out-of-the box support for GitHub
.