Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix!: Bump clap to v4 #43

Merged
merged 2 commits into from Sep 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .clippy.toml
@@ -1 +1 @@
msrv = "1.56.1" # MSRV
msrv = "1.60.0" # MSRV
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Expand Up @@ -51,15 +51,15 @@ jobs:
- name: No-default features
run: cargo test --workspace --no-default-features
msrv:
name: "Check MSRV: 1.56.1"
name: "Check MSRV: 1.60.0"
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: 1.56.1 # MSRV
toolchain: 1.60.0 # MSRV
profile: minimal
override: true
- uses: Swatinem/rust-cache@v1
Expand Down Expand Up @@ -113,7 +113,7 @@ jobs:
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: 1.56.1 # MSRV
toolchain: 1.60.0 # MSRV
profile: minimal
override: true
components: clippy
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/rust-next.yml
Expand Up @@ -57,9 +57,9 @@ jobs:
strategy:
matrix:
rust:
- 1.56.1 # MSRV
- 1.60.0 # MSRV
- stable
continue-on-error: ${{ matrix.rust != '1.56.1' }} # MSRV
continue-on-error: ${{ matrix.rust != '1.60.0' }} # MSRV
runs-on: ubuntu-latest
steps:
- name: Checkout repository
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Expand Up @@ -7,7 +7,7 @@ license = "MIT OR Apache-2.0"
repository = "https://github.com/rust-clique/clap-verbosity-flag"
readme = "README.md"
edition = "2021"
rust-version = "1.56.1" # MSRV
rust-version = "1.60.0" # MSRV
include = [
"src/**/*",
"Cargo.toml",
Expand All @@ -30,7 +30,7 @@ codecov = { repository = "rust-cli/clap-verbosity-flag" }

[dependencies]
log = "0.4.1"
clap = { version = "3.0", default-features = false, features = ["std", "derive"] }
clap = { version = "4.0.0", default-features = false, features = ["std", "derive"] }

[dev-dependencies]
env_logger = "0.9.0"
Expand Down
24 changes: 12 additions & 12 deletions src/lib.rs
Expand Up @@ -11,7 +11,7 @@
//! # /// Le CLI
//! # #[derive(Debug, Parser)]
//! # struct Cli {
//! #[clap(flatten)]
//! #[command(flatten)]
//! verbose: Verbosity,
//! # }
//! ```
Expand All @@ -24,7 +24,7 @@
//! # /// Le CLI
//! # #[derive(Debug, Parser)]
//! # struct Cli {
//! # #[clap(flatten)]
//! # #[command(flatten)]
//! # verbose: Verbosity,
//! # }
//! let cli = Cli::parse();
Expand All @@ -48,7 +48,7 @@
//! /// Le CLI
//! #[derive(Debug, Parser)]
//! struct Cli {
//! #[clap(flatten)]
//! #[command(flatten)]
//! verbose: Verbosity<InfoLevel>,
//! }
//! ```
Expand All @@ -57,34 +57,34 @@

#[derive(clap::Args, Debug, Clone)]
pub struct Verbosity<L: LogLevel = ErrorLevel> {
#[clap(
#[arg(
long,
short = 'v',
parse(from_occurrences),
action = clap::ArgAction::Count,
global = true,
help = L::verbose_help(),
long_help = L::verbose_long_help(),
)]
verbose: i8,
verbose: u8,

#[clap(
#[arg(
long,
short = 'q',
parse(from_occurrences),
action = clap::ArgAction::Count,
global = true,
help = L::quiet_help(),
long_help = L::quiet_long_help(),
conflicts_with = "verbose",
)]
quiet: i8,
quiet: u8,

#[clap(skip)]
#[arg(skip)]
phantom: std::marker::PhantomData<L>,
}

impl<L: LogLevel> Verbosity<L> {
/// Create a new verbosity instance by explicitly setting the values
pub fn new(verbose: i8, quiet: i8) -> Self {
pub fn new(verbose: u8, quiet: u8) -> Self {
Verbosity {
verbose,
quiet,
Expand Down Expand Up @@ -112,7 +112,7 @@ impl<L: LogLevel> Verbosity<L> {
}

fn verbosity(&self) -> i8 {
level_value(L::default()) - self.quiet + self.verbose
level_value(L::default()) - (self.quiet as i8) + (self.verbose as i8)
}
}

Expand Down