Compare commits

..

No commits in common. "d9cdd183767f465f7483a0dc2961e44d6dac5014" and "c9c835188b1b0d0392afb7aaab8b21ab4257d5b8" have entirely different histories.

2 changed files with 6 additions and 13 deletions

View file

@ -16,8 +16,8 @@ categories.workspace = true
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
[features]
default = []
log = ["dep:log"]
default = ["log"]
log = ["dep:libpt-log", "dep:log"]
[dependencies]
anyhow.workspace = true
@ -29,7 +29,7 @@ embed-doc-image = "0.1.4"
exitcode = "1.1.2"
human-panic = "2.0.0"
indicatif = "0.17.8"
libpt-log = { workspace = true, optional = false }
libpt-log = { workspace = true, optional = true }
log = { version = "0.4.21", optional = true }
shlex = "1.3.0"
strum = { version = "0.26.3", features = ["derive"] }

View file

@ -1,6 +1,7 @@
//! Utilities for parsing options and arguments on the start of a CLI application
use clap::Parser;
#[cfg(feature = "log")]
use libpt_log::Level;
#[cfg(feature = "log")]
use log;
@ -99,6 +100,7 @@ Author: {author-with-newline}
/// }
/// ```
#[derive(Parser, Clone, PartialEq, Eq, Hash)]
#[cfg(feature = "log")]
pub struct VerbosityLevel {
/// make the output more verbose
#[arg(
@ -133,7 +135,6 @@ impl VerbosityLevel {
self.verbose != 0 || self.quiet != 0
}
#[inline]
#[must_use]
fn value(&self) -> i8 {
Self::level_value(Level::INFO)
.saturating_sub((self.quiet).min(10))
@ -179,7 +180,6 @@ impl VerbosityLevel {
/// [None] means that absolutely no output is wanted (completely quiet)
#[inline]
#[must_use]
#[cfg(feature = "log")]
pub fn level_for_log_crate(&self) -> log::Level {
match self.level() {
Level::TRACE => log::Level::Trace,
@ -191,8 +191,7 @@ impl VerbosityLevel {
}
#[inline]
#[must_use]
const fn level_value(level: Level) -> i8 {
fn level_value(level: Level) -> i8 {
match level {
Level::TRACE => 4,
Level::DEBUG => 3,
@ -275,9 +274,3 @@ impl std::fmt::Debug for VerbosityLevel {
write!(f, "{:?}", self.level())
}
}
impl Default for VerbosityLevel {
fn default() -> Self {
Self::INFO
}
}