mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 14:21:44 +00:00
add quiet mode to analysis-stats
This commit is contained in:
parent
7828f43303
commit
a31933e4b5
3 changed files with 116 additions and 82 deletions
|
@ -12,6 +12,22 @@ use ra_syntax::{AstNode, SourceFile};
|
|||
|
||||
type Result<T> = std::result::Result<T, Box<dyn Error + Send + Sync>>;
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub enum Verbosity {
|
||||
Verbose,
|
||||
Normal,
|
||||
Quiet,
|
||||
}
|
||||
|
||||
impl Verbosity {
|
||||
fn is_verbose(&self) -> bool {
|
||||
match self {
|
||||
Verbosity::Verbose => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() -> Result<()> {
|
||||
Logger::with_env().start()?;
|
||||
|
||||
|
@ -67,7 +83,15 @@ fn main() -> Result<()> {
|
|||
eprintln!("{}", help::ANALYSIS_STATS_HELP);
|
||||
return Ok(());
|
||||
}
|
||||
let verbose = matches.contains(["-v", "--verbose"]);
|
||||
let verbosity = match (
|
||||
matches.contains(["-v", "--verbose"]),
|
||||
matches.contains(["-q", "--quiet"]),
|
||||
) {
|
||||
(false, false) => Verbosity::Normal,
|
||||
(false, true) => Verbosity::Quiet,
|
||||
(true, false) => Verbosity::Verbose,
|
||||
(true, true) => Err("Invalid flags: -q conflicts with -v")?,
|
||||
};
|
||||
let memory_usage = matches.contains("--memory-usage");
|
||||
let only = matches.value_from_str(["-o", "--only"])?.map(|v: String| v.to_owned());
|
||||
let path = {
|
||||
|
@ -79,7 +103,7 @@ fn main() -> Result<()> {
|
|||
trailing.pop().unwrap()
|
||||
};
|
||||
analysis_stats::run(
|
||||
verbose,
|
||||
verbosity,
|
||||
memory_usage,
|
||||
path.as_ref(),
|
||||
only.as_ref().map(String::as_ref),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue