#clap #structopt #cli #flags

structopt-flags

Collection of reusable flags for StructOpt

6 releases

✓ Uses Rust 2018 edition

new 0.3.2 May 21, 2019
0.3.1 Apr 18, 2019
0.2.1 Nov 2, 2018
0.2.0 Oct 15, 2018
0.1.0 Oct 7, 2018

#55 in Command-line interface

Download history 8/week @ 2019-02-05 7/week @ 2019-02-12 5/week @ 2019-02-19 14/week @ 2019-02-26 12/week @ 2019-03-05 1/week @ 2019-03-12 12/week @ 2019-03-19 24/week @ 2019-03-26 18/week @ 2019-04-02 21/week @ 2019-04-09 18/week @ 2019-04-16 22/week @ 2019-04-23 15/week @ 2019-04-30 8/week @ 2019-05-07 15/week @ 2019-05-14

61 downloads per month

BSD-3-Clause

32KB
416 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

~2.5MB
~40K SLoC