5 releases (breaking)

0.5.0 Mar 2, 2020
0.4.0 May 26, 2019
0.3.0 Aug 22, 2018
0.2.0 Aug 6, 2018
0.1.0 Aug 6, 2018

#892 in Data structures


Used in 3 crates

MIT/Apache

23KB
90 lines

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

Dependencies

~5–14MB
~154K SLoC