#clap #structopt #cli #flags

structopt-flags

Collection of reusable flags for StructOpt

9 releases

✓ Uses Rust 2018 edition

0.3.5 Sep 22, 2019
0.3.4 Aug 13, 2019
0.3.2 May 21, 2019
0.3.1 Apr 18, 2019
0.1.0 Oct 7, 2018

#56 in Command-line interface

Download history 40/week @ 2019-08-15 51/week @ 2019-08-22 79/week @ 2019-08-29 46/week @ 2019-09-05 62/week @ 2019-09-12 151/week @ 2019-09-19 55/week @ 2019-09-26 39/week @ 2019-10-03 82/week @ 2019-10-10 97/week @ 2019-10-17 56/week @ 2019-10-24 41/week @ 2019-10-31 19/week @ 2019-11-07 19/week @ 2019-11-14 33/week @ 2019-11-21

241 downloads per month

BSD-3-Clause

32KB
436 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.3"

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(())
}

simplelog Feature

A non-default feature added in version 0.3 is an API to automatically configure simplelog depending on you log or verbosity level. To use this feature, add in your Cargo.toml

[dependencies]
structopt-flags = { version = "0.3", features = ["simplelog"] }

License

Licensed under:

Dependencies

~1.8–2.5MB
~43K SLoC