#clap #structopt #cli #flags

structopt-flags

Collection of reusable flags for StructOpt

3 unstable releases

0.2.1 Nov 2, 2018
0.2.0 Oct 15, 2018
0.1.0 Oct 7, 2018

#75 in Command-line interface

Download history 4/week @ 2018-10-21 31/week @ 2018-10-28 50/week @ 2018-11-04 16/week @ 2018-11-11 6/week @ 2018-11-18 15/week @ 2018-11-25 15/week @ 2018-12-02 15/week @ 2018-12-09 11/week @ 2018-12-16 49/week @ 2018-12-23 14/week @ 2018-12-30 13/week @ 2019-01-06 12/week @ 2019-01-13 2/week @ 2019-01-20 31/week @ 2019-01-27

91 downloads per month

BSD-3-Clause

25KB
333 lines

structopt-flags

Build Status Docs dependency status

A set of reusable flags and option for your CLIs using StructOpt

Getting started

Add the crate to your project, adding this in Cargo.toml:

[dependencies]
structopt-flags = "0.2"

In your code, you can use one or more flags provided by this crate. For instance:

extern crate failure;
#[allow(unused_imports)]
#[macro_use]
extern crate structopt;
extern crate structopt_flags;

use failure::Error;
use structopt::StructOpt;
use structopt_flags::LogLevel; // traits for flags that can provide a log level

#[derive(Debug, StructOpt)]
#[structopt(name = "verbose", about = "An example using verbose flag")]
struct Opt {
    #[structopt(flatten)]
    verbose: structopt_flags::Verbose,
}

fn main() -> Result<(), Error> {
    let opt = Opt::from_args();
	let _log_level = opt.verbose.get_level_filter();
	// set the log level of your preferred log crate
    Ok(())
}

License

Licensed under:

Dependencies

~2.5MB
~40K SLoC