#flags #structopt #clap #logging #cli

structopt-flags

Collection of reusable flags for StructOpt

10 releases

0.3.6 Jul 28, 2020
0.3.5 Sep 22, 2019
0.3.4 Aug 13, 2019
0.3.2 May 21, 2019
0.1.0 Oct 7, 2018

#776 in Command-line interface

Download history 84/week @ 2024-09-18 82/week @ 2024-09-25 72/week @ 2024-10-02 42/week @ 2024-10-09 48/week @ 2024-10-16 53/week @ 2024-10-23 50/week @ 2024-10-30 45/week @ 2024-11-06 35/week @ 2024-11-13 40/week @ 2024-11-20 60/week @ 2024-11-27 69/week @ 2024-12-04 114/week @ 2024-12-11 57/week @ 2024-12-18 9/week @ 2024-12-25 53/week @ 2025-01-01

246 downloads per month
Used in 8 crates

BSD-3-Clause

32KB
418 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 structopt;
extern crate structopt_flags;

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() {
    let opt = Opt::from_args();
	let _log_level = opt.verbose.get_level_filter();
	// set the log level of your preferred log crate
}

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

~3.5–5.5MB
~94K SLoC