Skip to content
This repository was archived by the owner on Sep 13, 2023. It is now read-only.

Commit e9fd9c0

Browse files
authored
Merge pull request #80 from killercup/log-level-fun
pub use clap_verbosity_flag::Verbosity;
2 parents 5db94a7 + 790ef79 commit e9fd9c0

File tree

11 files changed

+582
-396
lines changed

11 files changed

+582
-396
lines changed

Cargo.lock

Lines changed: 558 additions & 357 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ failure = "0.1.1"
1515
failure_derive = "0.1.1"
1616
serde = { version="1.0.27", optional = true}
1717
serde_derive = { version="1.0.27", optional = true }
18-
structopt = "0.2"
19-
structopt-derive = "0.2"
18+
structopt = "0.2.8"
19+
structopt-derive = "0.2.8"
2020
log = "0.4.1"
2121
env_logger = "0.5.3"
2222
glob = { version = "0.2.11", optional = true }
2323
rayon = { version = "1.0", optional = true }
24+
clap-verbosity-flag = "0.1.0"
2425

2526
[features]
2627
default = ["full-throttle"]

docs/Readme.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ struct Cli {
7676
// Add a positional argument that the user has to supply:
7777
/// The file to read
7878
file: String,
79-
/// Pass many times for more log output
80-
#[structopt(long = "verbose", short = "v", parse(from_occurrences))]
81-
verbosity: u8,
79+
// Quick and easy logging setup you get for free with quicli
80+
#[structopt(flatten)]
81+
verbosity: Verbosity,
8282
}
8383
```
8484

docs/commit.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,8 @@ struct Cli {
7676
/// How many?
7777
#[structopt(long = "amount", default_value = "3")]
7878
amount: i32,
79-
/// Pass many times for more log output
80-
#[structopt(long = "verbosity", short = "v", parse(from_occurrences))]
81-
verbosity: u8,
79+
#[structopt(flatten)]
80+
verbosity: Verbosity,
8281
}
8382
```
8483

docs/thumbnails.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,8 @@ Here we go:
7575
/// Make some thumbnails
7676
#[derive(Debug, StructOpt)]
7777
struct Cli {
78-
/// Pass many times for more log output
79-
#[structopt(long = "verbosity", short = "v", parse(from_occurrences))]
80-
verbosity: u8,
78+
#[structopt(flatten)]
79+
verbosity: Verbosity,
8180
```
8281

8382
So far so typical for a _quicli_ app.

examples/Readme/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ struct Cli {
1111
// Add a positional argument that the user has to supply:
1212
/// The file to read
1313
file: String,
14-
/// Pass many times for more log output
15-
#[structopt(long = "verbose", short = "v", parse(from_occurrences))]
16-
verbosity: u8,
14+
// Quick and easy logging setup you get for free with quicli
15+
#[structopt(flatten)]
16+
verbosity: Verbosity,
1717
}
1818
main!(|args: Cli, log_level: verbosity| {
1919
let content = read_file(&args.file)?;

examples/commit/src/main.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ struct Cli {
88
/// How many?
99
#[structopt(long = "amount", default_value = "3")]
1010
amount: i32,
11-
/// Pass many times for more log output
12-
#[structopt(long = "verbosity", short = "v", parse(from_occurrences))]
13-
verbosity: u8,
11+
#[structopt(flatten)]
12+
verbosity: Verbosity,
1413
}
1514
#[derive(Deserialize)]
1615
struct Commit {

examples/thumbnails/src/main.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ use quicli::prelude::*;
44
/// Make some thumbnails
55
#[derive(Debug, StructOpt)]
66
struct Cli {
7-
/// Pass many times for more log output
8-
#[structopt(long = "verbosity", short = "v", parse(from_occurrences))]
9-
verbosity: u8,
7+
#[structopt(flatten)]
8+
verbosity: Verbosity,
109
/// Which files?
1110
#[structopt(default_value = "*.jpg")]
1211
pattern: String,

examples/verbosity/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use quicli::prelude::*;
55
/// Verbosity by any other name is still as verbose
66
#[derive(Debug, StructOpt)]
77
struct Cli {
8-
#[structopt(long = "verbose", short = "v", parse(from_occurrences))]
9-
team_rockets_blasting_off_again: u8,
8+
#[structopt(flatten)]
9+
team_rockets_blasting_off_again: Verbosity,
1010
}
1111

1212
main!(|cli_args: Cli, log_level: team_rockets_blasting_off_again| {

src/lib.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ extern crate failure;
2525
extern crate log;
2626
extern crate env_logger;
2727

28+
extern crate clap_verbosity_flag;
29+
2830
#[cfg(feature = "full-throttle")]
2931
extern crate rayon;
3032

@@ -46,6 +48,8 @@ mod reexports {
4648
#[doc(hidden)]
4749
pub use structopt::StructOpt;
4850

51+
pub use clap_verbosity_flag::Verbosity;
52+
4953
#[doc(hidden)]
5054
pub use failure_derive::*;
5155
#[doc(hidden)]
@@ -73,9 +77,4 @@ pub mod prelude {
7377

7478
#[cfg(feature = "full-throttle")]
7579
pub use fs::*;
76-
77-
#[doc(hidden)]
78-
pub use env_logger::Builder as LoggerBuilder;
79-
#[doc(hidden)]
80-
pub use log::Level as LogLevel;
8180
}

0 commit comments

Comments
 (0)