#disk #disk-usage

autoclap

๐Ÿ‘ Auto-propagate Cargo.toml infos (name, version, author, repo) into app

18 releases

Uses new Rust 2021

0.3.10 Nov 17, 2022
0.3.9 Oct 22, 2022
0.2.10 Oct 2, 2022
0.2.5 Sep 29, 2022
0.0.3 Jan 28, 2022

#376 in Development tools

Download history 109/week @ 2022-08-09 48/week @ 2022-08-16 36/week @ 2022-08-23 28/week @ 2022-08-30 97/week @ 2022-09-06 86/week @ 2022-09-13 138/week @ 2022-09-20 428/week @ 2022-09-27 276/week @ 2022-10-04 261/week @ 2022-10-11 131/week @ 2022-10-18 81/week @ 2022-10-25 107/week @ 2022-11-01 50/week @ 2022-11-08 94/week @ 2022-11-15 38/week @ 2022-11-22

296 downloads per month
Used in 5 crates

MIT license

5KB
62 lines

autoclap

CD-auto

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.

Why?

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.

Usage

use clap::Command;
use autoclap::autoclap;

fn main() {
    let app = autoclap!();

    app.arg(
        Arg::with_name("myarg")
            .long("myarg")
            .short('m')
            .help("My arg description."),
    )
    .get_matches_safe()
    .unwrap_or_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.

Releases

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.

Dependencies

~1MB
~17K SLoC