diff options
-rw-r--r-- | crates/ra_cli/src/analysis_bench.rs | 10 | ||||
-rw-r--r-- | crates/ra_cli/src/main.rs | 34 |
2 files changed, 22 insertions, 22 deletions
diff --git a/crates/ra_cli/src/analysis_bench.rs b/crates/ra_cli/src/analysis_bench.rs index 3f10ed400..83f95555f 100644 --- a/crates/ra_cli/src/analysis_bench.rs +++ b/crates/ra_cli/src/analysis_bench.rs | |||
@@ -13,7 +13,7 @@ use ra_db::{ | |||
13 | }; | 13 | }; |
14 | use ra_ide::{Analysis, AnalysisChange, AnalysisHost, FilePosition, LineCol}; | 14 | use ra_ide::{Analysis, AnalysisChange, AnalysisHost, FilePosition, LineCol}; |
15 | 15 | ||
16 | use crate::{load_cargo::load_cargo, Result}; | 16 | use crate::{load_cargo::load_cargo, Result, Verbosity}; |
17 | 17 | ||
18 | pub(crate) struct Position { | 18 | pub(crate) struct Position { |
19 | path: PathBuf, | 19 | path: PathBuf, |
@@ -41,7 +41,7 @@ pub(crate) enum Op { | |||
41 | GotoDef(Position), | 41 | GotoDef(Position), |
42 | } | 42 | } |
43 | 43 | ||
44 | pub(crate) fn run(verbose: bool, path: &Path, op: Op) -> Result<()> { | 44 | pub(crate) fn run(verbosity: Verbosity, path: &Path, op: Op) -> Result<()> { |
45 | ra_prof::init(); | 45 | ra_prof::init(); |
46 | 46 | ||
47 | let start = Instant::now(); | 47 | let start = Instant::now(); |
@@ -79,7 +79,7 @@ pub(crate) fn run(verbose: bool, path: &Path, op: Op) -> Result<()> { | |||
79 | analysis.diagnostics(file_id).unwrap(); | 79 | analysis.diagnostics(file_id).unwrap(); |
80 | analysis.highlight_as_html(file_id, false).unwrap() | 80 | analysis.highlight_as_html(file_id, false).unwrap() |
81 | }); | 81 | }); |
82 | if verbose { | 82 | if verbosity.is_verbose() { |
83 | println!("\n{}", res); | 83 | println!("\n{}", res); |
84 | } | 84 | } |
85 | } | 85 | } |
@@ -98,13 +98,13 @@ pub(crate) fn run(verbose: bool, path: &Path, op: Op) -> Result<()> { | |||
98 | if is_completion { | 98 | if is_completion { |
99 | let res = | 99 | let res = |
100 | do_work(&mut host, file_id, |analysis| analysis.completions(file_postion)); | 100 | do_work(&mut host, file_id, |analysis| analysis.completions(file_postion)); |
101 | if verbose { | 101 | if verbosity.is_verbose() { |
102 | println!("\n{:#?}", res); | 102 | println!("\n{:#?}", res); |
103 | } | 103 | } |
104 | } else { | 104 | } else { |
105 | let res = | 105 | let res = |
106 | do_work(&mut host, file_id, |analysis| analysis.goto_definition(file_postion)); | 106 | do_work(&mut host, file_id, |analysis| analysis.goto_definition(file_postion)); |
107 | if verbose { | 107 | if verbosity.is_verbose() { |
108 | println!("\n{:#?}", res); | 108 | println!("\n{:#?}", res); |
109 | } | 109 | } |
110 | } | 110 | } |
diff --git a/crates/ra_cli/src/main.rs b/crates/ra_cli/src/main.rs index f952d0f6c..58fea2cd4 100644 --- a/crates/ra_cli/src/main.rs +++ b/crates/ra_cli/src/main.rs | |||
@@ -48,8 +48,8 @@ fn main() -> Result<()> { | |||
48 | randomize, | 48 | randomize, |
49 | )?; | 49 | )?; |
50 | } | 50 | } |
51 | Command::Bench { verbose, path, op } => { | 51 | Command::Bench { verbosity, path, op } => { |
52 | analysis_bench::run(verbose, path.as_ref(), op)?; | 52 | analysis_bench::run(verbosity, path.as_ref(), op)?; |
53 | } | 53 | } |
54 | Command::HelpPrinted => (), | 54 | Command::HelpPrinted => (), |
55 | } | 55 | } |
@@ -97,7 +97,7 @@ enum Command { | |||
97 | path: PathBuf, | 97 | path: PathBuf, |
98 | }, | 98 | }, |
99 | Bench { | 99 | Bench { |
100 | verbose: bool, | 100 | verbosity: Verbosity, |
101 | path: PathBuf, | 101 | path: PathBuf, |
102 | op: analysis_bench::Op, | 102 | op: analysis_bench::Op, |
103 | }, | 103 | }, |
@@ -109,6 +109,19 @@ impl Command { | |||
109 | let mut matches = Arguments::from_env(); | 109 | let mut matches = Arguments::from_env(); |
110 | let subcommand = matches.subcommand()?.unwrap_or_default(); | 110 | let subcommand = matches.subcommand()?.unwrap_or_default(); |
111 | 111 | ||
112 | let verbosity = match ( | ||
113 | matches.contains(["-vv", "--spammy"]), | ||
114 | matches.contains(["-v", "--verbose"]), | ||
115 | matches.contains(["-q", "--quiet"]), | ||
116 | ) { | ||
117 | (true, _, true) => Err("Invalid flags: -q conflicts with -vv")?, | ||
118 | (true, _, false) => Verbosity::Spammy, | ||
119 | (false, false, false) => Verbosity::Normal, | ||
120 | (false, false, true) => Verbosity::Quiet, | ||
121 | (false, true, false) => Verbosity::Verbose, | ||
122 | (false, true, true) => Err("Invalid flags: -q conflicts with -v")?, | ||
123 | }; | ||
124 | |||
112 | let command = match subcommand.as_str() { | 125 | let command = match subcommand.as_str() { |
113 | "parse" => { | 126 | "parse" => { |
114 | if matches.contains(["-h", "--help"]) { | 127 | if matches.contains(["-h", "--help"]) { |
@@ -193,18 +206,6 @@ ARGS: | |||
193 | return Ok(Command::HelpPrinted); | 206 | return Ok(Command::HelpPrinted); |
194 | } | 207 | } |
195 | 208 | ||
196 | let verbosity = match ( | ||
197 | matches.contains(["-vv", "--spammy"]), | ||
198 | matches.contains(["-v", "--verbose"]), | ||
199 | matches.contains(["-q", "--quiet"]), | ||
200 | ) { | ||
201 | (true, _, true) => Err("Invalid flags: -q conflicts with -vv")?, | ||
202 | (true, _, false) => Verbosity::Spammy, | ||
203 | (false, false, false) => Verbosity::Normal, | ||
204 | (false, false, true) => Verbosity::Quiet, | ||
205 | (false, true, false) => Verbosity::Verbose, | ||
206 | (false, true, true) => Err("Invalid flags: -q conflicts with -v")?, | ||
207 | }; | ||
208 | let randomize = matches.contains("--randomize"); | 209 | let randomize = matches.contains("--randomize"); |
209 | let memory_usage = matches.contains("--memory-usage"); | 210 | let memory_usage = matches.contains("--memory-usage"); |
210 | let only: Option<String> = matches.opt_value_from_str(["-o", "--only"])?; | 211 | let only: Option<String> = matches.opt_value_from_str(["-o", "--only"])?; |
@@ -242,7 +243,6 @@ ARGS: | |||
242 | return Ok(Command::HelpPrinted); | 243 | return Ok(Command::HelpPrinted); |
243 | } | 244 | } |
244 | 245 | ||
245 | let verbose = matches.contains(["-v", "--verbose"]); | ||
246 | let path: PathBuf = matches.opt_value_from_str("--path")?.unwrap_or_default(); | 246 | let path: PathBuf = matches.opt_value_from_str("--path")?.unwrap_or_default(); |
247 | let highlight_path: Option<String> = matches.opt_value_from_str("--highlight")?; | 247 | let highlight_path: Option<String> = matches.opt_value_from_str("--highlight")?; |
248 | let complete_path: Option<String> = matches.opt_value_from_str("--complete")?; | 248 | let complete_path: Option<String> = matches.opt_value_from_str("--complete")?; |
@@ -255,7 +255,7 @@ ARGS: | |||
255 | "exactly one of `--highlight`, `--complete` or `--goto-def` must be set" | 255 | "exactly one of `--highlight`, `--complete` or `--goto-def` must be set" |
256 | ), | 256 | ), |
257 | }; | 257 | }; |
258 | Command::Bench { verbose, path, op } | 258 | Command::Bench { verbosity, path, op } |
259 | } | 259 | } |
260 | _ => { | 260 | _ => { |
261 | eprintln!( | 261 | eprintln!( |