Support loading OUT_DIR for CLI runs

This commit is contained in:
Emil Lauridsen
2020-03-16 14:51:44 +01:00
parent 9e7dbb1abd
commit f84deffd72
5 changed files with 80 additions and 47 deletions

View File

@@ -28,10 +28,12 @@ pub(crate) enum Command {
only: Option<String>,
with_deps: bool,
path: PathBuf,
load_output_dirs: bool,
},
Bench {
path: PathBuf,
what: BenchWhat,
load_output_dirs: bool,
},
RunServer,
Version,
@@ -136,8 +138,9 @@ USAGE:
rust-analyzer analysis-stats [FLAGS] [OPTIONS] [PATH]
FLAGS:
-h, --help Prints help information
-h, --help Prints help information
--memory-usage
--load-output-dirs Load OUT_DIR values by running `cargo check` before analysis
-v, --verbose
-q, --quiet
@@ -154,6 +157,7 @@ ARGS:
let memory_usage = matches.contains("--memory-usage");
let only: Option<String> = matches.opt_value_from_str(["-o", "--only"])?;
let with_deps: bool = matches.contains("--with-deps");
let load_output_dirs = matches.contains("--load-output-dirs");
let path = {
let mut trailing = matches.free()?;
if trailing.len() != 1 {
@@ -162,7 +166,7 @@ ARGS:
trailing.pop().unwrap().into()
};
Command::Stats { randomize, memory_usage, only, with_deps, path }
Command::Stats { randomize, memory_usage, only, with_deps, path, load_output_dirs }
}
"analysis-bench" => {
if matches.contains(["-h", "--help"]) {
@@ -174,7 +178,8 @@ USAGE:
rust-analyzer analysis-bench [FLAGS] [OPTIONS]
FLAGS:
-h, --help Prints help information
-h, --help Prints help information
--load-output-dirs Load OUT_DIR values by running `cargo check` before analysis
-v, --verbose
OPTIONS:
@@ -201,7 +206,8 @@ ARGS:
"exactly one of `--highlight`, `--complete` or `--goto-def` must be set"
),
};
Command::Bench { path, what }
let load_output_dirs = matches.contains("--load-output-dirs");
Command::Bench { path, what, load_output_dirs }
}
_ => {
eprintln!(

View File

@@ -19,19 +19,25 @@ 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, memory_usage, only, with_deps, path } => {
cli::analysis_stats(
args.verbosity,
memory_usage,
path.as_ref(),
only.as_ref().map(String::as_ref),
with_deps,
randomize,
)?
}
args::Command::Stats {
randomize,
memory_usage,
only,
with_deps,
path,
load_output_dirs,
} => cli::analysis_stats(
args.verbosity,
memory_usage,
path.as_ref(),
only.as_ref().map(String::as_ref),
with_deps,
randomize,
load_output_dirs,
)?,
args::Command::Bench { path, what } => {
cli::analysis_bench(args.verbosity, path.as_ref(), what)?
args::Command::Bench { path, what, load_output_dirs } => {
cli::analysis_bench(args.verbosity, path.as_ref(), what, load_output_dirs)?
}
args::Command::RunServer => run_server()?,