CLI Batteries

crates.io docs.rs MIT License dependency status codecov CI

Opinionated batteries-included command line interface runtime utilities.

To use it, add it to your Cargo.toml

```toml [dependencies] cli-batteries = "0.1"

[build-dependencies] cli-batteries = "0.1" ```

and call the [build_rs] function in your build.rs

rust,ignore fn main() { cli_batteries::build_rs().unwrap() }

Then in your src/main.rs you define app specific command line arguments using [clap::Parser][clap] and run the app as follows

```rust,ignore use cli_batteries::{version, Parser}; use std::{path::PathBuf, io::Result}; use tokio::fs::File;

[derive(Parser)]

[group(skip)]

struct Options { /// File to read #[clap(long, env, default_value = "Readme.md")] file: PathBuf, }

async fn app(options: Options) -> Result<()> { let mut file = File::open(options.file).await?; Ok(()) }

fn main() { cli_batteries::run(version!(), app); } ```

You can see this working in the example project.

Features

Building and testing

Format, lint, build and test everything (I recommend creating a shell alias for this):

sh cargo fmt &&\ cargo clippy --all-features --all-targets &&\ cargo test --workspace --all-features --doc -- --nocapture &&\ cargo test --workspace --all-features --all-targets -- --nocapture &&\ cargo doc --workspace --all-features --no-deps

Check documentation coverage

sh RUSTDOCFLAGS="-Z unstable-options --show-coverage" cargo doc --workspace --all-features --no-deps

To do

Goals:

Maybe:


lines of code GitHub contributors GitHub issues GitHub pull requests GitHub Repo stars crates.io