Skip to content

Commit bdf2558

Browse files
committed
allow verbose logs in clang-tools binary
1 parent bc074ab commit bdf2558

1 file changed

Lines changed: 21 additions & 7 deletions

File tree

clang-installer/src/main.rs

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,27 @@ mod logging {
9999
pub struct CliOptions {
100100
/// The desired version of clang to install.
101101
#[arg(
102-
short,
103-
long,
104-
default_missing_value = "CPP-LINTER-VERSION",
105-
num_args = 0..=1,
106-
value_parser = RequestedVersion::from_str,
107-
default_value = "",
102+
short,
103+
long,
104+
default_missing_value = "CPP-LINTER-VERSION",
105+
num_args = 0..=1,
106+
value_parser = RequestedVersion::from_str,
107+
default_value = "",
108108
)]
109109
pub version: Option<RequestedVersion>,
110110

111+
/// Enable verbose logging for debugging purposes.
112+
///
113+
/// This will include more DEBUG level log messages.
114+
/// Without it, log level is set to INFO by default.
115+
#[arg(
116+
short = 'V',
117+
long,
118+
default_value_t = false,
119+
action = clap::ArgAction::SetTrue,
120+
)]
121+
pub verbose: bool,
122+
111123
/// The clang tool to install.
112124
#[arg(
113125
short,
@@ -132,7 +144,9 @@ pub struct CliOptions {
132144
async fn main() -> Result<()> {
133145
logging::initialize_logger();
134146
let options = CliOptions::parse();
135-
147+
if options.verbose {
148+
log::set_max_level(log::LevelFilter::Debug);
149+
}
136150
let tool = options
137151
.tool
138152
.expect("--tool should have a default value: [clang-format, clang-tidy]");

0 commit comments

Comments
 (0)