Use CmdArgs pattern for bench & analysis stats
This commit is contained in:
@@ -8,7 +8,7 @@ use std::{env, fmt::Write, path::PathBuf};
|
||||
use anyhow::{bail, Result};
|
||||
use pico_args::Arguments;
|
||||
use ra_ssr::{SsrPattern, SsrRule};
|
||||
use rust_analyzer::cli::{BenchWhat, Position, Verbosity};
|
||||
use rust_analyzer::cli::{AnalysisStatsCmd, BenchCmd, BenchWhat, Position, Verbosity};
|
||||
use vfs::AbsPathBuf;
|
||||
|
||||
pub(crate) struct Args {
|
||||
@@ -24,23 +24,8 @@ pub(crate) enum Command {
|
||||
Highlight {
|
||||
rainbow: bool,
|
||||
},
|
||||
Stats {
|
||||
randomize: bool,
|
||||
parallel: bool,
|
||||
memory_usage: bool,
|
||||
only: Option<String>,
|
||||
with_deps: bool,
|
||||
path: PathBuf,
|
||||
load_output_dirs: bool,
|
||||
with_proc_macro: bool,
|
||||
},
|
||||
Bench {
|
||||
memory_usage: bool,
|
||||
path: PathBuf,
|
||||
what: BenchWhat,
|
||||
load_output_dirs: bool,
|
||||
with_proc_macro: bool,
|
||||
},
|
||||
AnalysisStats(AnalysisStatsCmd),
|
||||
Bench(BenchCmd),
|
||||
Diagnostics {
|
||||
path: PathBuf,
|
||||
load_output_dirs: bool,
|
||||
@@ -199,7 +184,7 @@ ARGS:
|
||||
trailing.pop().unwrap().into()
|
||||
};
|
||||
|
||||
Command::Stats {
|
||||
Command::AnalysisStats(AnalysisStatsCmd {
|
||||
randomize,
|
||||
parallel,
|
||||
memory_usage,
|
||||
@@ -208,7 +193,7 @@ ARGS:
|
||||
path,
|
||||
load_output_dirs,
|
||||
with_proc_macro,
|
||||
}
|
||||
})
|
||||
}
|
||||
"analysis-bench" => {
|
||||
if matches.contains(["-h", "--help"]) {
|
||||
@@ -256,7 +241,13 @@ ARGS:
|
||||
let memory_usage = matches.contains("--memory-usage");
|
||||
let load_output_dirs = matches.contains("--load-output-dirs");
|
||||
let with_proc_macro = matches.contains("--with-proc-macro");
|
||||
Command::Bench { memory_usage, path, what, load_output_dirs, with_proc_macro }
|
||||
Command::Bench(BenchCmd {
|
||||
memory_usage,
|
||||
path,
|
||||
what,
|
||||
load_output_dirs,
|
||||
with_proc_macro,
|
||||
})
|
||||
}
|
||||
"diagnostics" => {
|
||||
if matches.contains(["-h", "--help"]) {
|
||||
|
||||
@@ -33,36 +33,8 @@ fn main() -> Result<()> {
|
||||
args::Command::Parse { no_dump } => cli::parse(no_dump)?,
|
||||
args::Command::Symbols => cli::symbols()?,
|
||||
args::Command::Highlight { rainbow } => cli::highlight(rainbow)?,
|
||||
args::Command::Stats {
|
||||
randomize,
|
||||
parallel,
|
||||
memory_usage,
|
||||
only,
|
||||
with_deps,
|
||||
path,
|
||||
load_output_dirs,
|
||||
with_proc_macro,
|
||||
} => cli::analysis_stats(
|
||||
args.verbosity,
|
||||
memory_usage,
|
||||
path.as_ref(),
|
||||
only.as_ref().map(String::as_ref),
|
||||
with_deps,
|
||||
randomize,
|
||||
parallel,
|
||||
load_output_dirs,
|
||||
with_proc_macro,
|
||||
)?,
|
||||
args::Command::Bench { memory_usage, path, what, load_output_dirs, with_proc_macro } => {
|
||||
cli::analysis_bench(
|
||||
args.verbosity,
|
||||
path.as_ref(),
|
||||
what,
|
||||
memory_usage,
|
||||
load_output_dirs,
|
||||
with_proc_macro,
|
||||
)?
|
||||
}
|
||||
args::Command::AnalysisStats(cmd) => cmd.run(args.verbosity)?,
|
||||
args::Command::Bench(cmd) => cmd.run(args.verbosity)?,
|
||||
args::Command::Diagnostics { path, load_output_dirs, with_proc_macro, all } => {
|
||||
cli::diagnostics(path.as_ref(), load_output_dirs, with_proc_macro, all)?
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user