clap_flags

Crates.ioclap_flags
lib.rsclap_flags
version0.5.0
sourcesrc
created_at2018-08-06 15:08:29.68048
updated_at2020-03-02 11:21:04.813128
descriptionCollection of reusable flags for Clap
homepage
repositoryhttps://github.com/yoshuawuyts/clap_flags
max_upload_size
id77766
size71,041
Yosh (yoshuawuyts)

documentation

https://docs.rs/clap_flags

README

clap_flags

crates.io version build status downloads docs.rs docs

Collection of reusable flags for Clap.

Usage

#[derive(structopt::StructOpt, paw_structopt::StructOpt)]
#[structopt(author = "", raw(setting = "structopt::clap::AppSettings::ColoredHelp"))]
struct Args {
    #[structopt(flatten)]
    address: clap_flags::Address,
    #[structopt(flatten)]
    logger: clap_flags::Log,
    #[structopt(flatten)]
    port: clap_flags::Port,
}

#[async_std::main]
#[paw::main]
async fn main(args: Args) -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
    args.logger.start(env!("CARGO_PKG_NAME"))?;
    let mut app = tide::new();
    app.at("/").get(async move |_| "Hello, world!");
    app.listen((&*args.address.address, args.port.port)).await?;
    Ok(())
}

Output

clap_flags 0.3.0
Collection of reusable flags for Clap

USAGE:
    main [FLAGS] [OPTIONS]

FLAGS:
    -h, --help         Prints help information
        --log-all      Enable log output from dependencies
    -P, --pretty       Enable pretty printing
    -q, --quiet        Suppress all log output
    -V, --version      Prints version information
    -v, --verbosity    Print more log output

OPTIONS:
    -a, --address <address>    Network address [default: 127.0.0.1]
    -p, --port <port>          Insecure HTTP port [env: PORT=]  [default: 80]

Installation

$ cargo add clap_flags

License

MIT OR Apache-2.0

Commit count: 24

cargo fmt