diff options
author | Aleksey Kladov <[email protected]> | 2020-02-17 17:03:48 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-02-17 17:03:48 +0000 |
commit | fa482a9fee6596f9b3021b188a2120873d5bb0d3 (patch) | |
tree | 92296cf90c8519a245d0bbc61b021a790390d7f8 /crates/ra_cli/src | |
parent | a51b2603f993dd02275d275d37bbd0a0f24dbe33 (diff) |
Move interesting stuff to main
Diffstat (limited to 'crates/ra_cli/src')
-rw-r--r-- | crates/ra_cli/src/main.rs | 75 |
1 files changed, 35 insertions, 40 deletions
diff --git a/crates/ra_cli/src/main.rs b/crates/ra_cli/src/main.rs index 42f0b3e17..f952d0f6c 100644 --- a/crates/ra_cli/src/main.rs +++ b/crates/ra_cli/src/main.rs | |||
@@ -18,7 +18,41 @@ fn main() -> Result<()> { | |||
18 | env_logger::try_init()?; | 18 | env_logger::try_init()?; |
19 | 19 | ||
20 | let command = Command::from_args()?; | 20 | let command = Command::from_args()?; |
21 | command.run()?; | 21 | match command { |
22 | Command::Parse { no_dump } => { | ||
23 | let _p = profile("parsing"); | ||
24 | let file = file()?; | ||
25 | if !no_dump { | ||
26 | println!("{:#?}", file.syntax()); | ||
27 | } | ||
28 | std::mem::forget(file); | ||
29 | } | ||
30 | Command::Symbols => { | ||
31 | let file = file()?; | ||
32 | for s in file_structure(&file) { | ||
33 | println!("{:?}", s); | ||
34 | } | ||
35 | } | ||
36 | Command::Highlight { rainbow } => { | ||
37 | let (analysis, file_id) = Analysis::from_single_file(read_stdin()?); | ||
38 | let html = analysis.highlight_as_html(file_id, rainbow).unwrap(); | ||
39 | println!("{}", html); | ||
40 | } | ||
41 | Command::Stats { verbosity, randomize, memory_usage, only, with_deps, path } => { | ||
42 | analysis_stats::run( | ||
43 | verbosity, | ||
44 | memory_usage, | ||
45 | path.as_ref(), | ||
46 | only.as_ref().map(String::as_ref), | ||
47 | with_deps, | ||
48 | randomize, | ||
49 | )?; | ||
50 | } | ||
51 | Command::Bench { verbose, path, op } => { | ||
52 | analysis_bench::run(verbose, path.as_ref(), op)?; | ||
53 | } | ||
54 | Command::HelpPrinted => (), | ||
55 | } | ||
22 | 56 | ||
23 | Ok(()) | 57 | Ok(()) |
24 | } | 58 | } |
@@ -246,45 +280,6 @@ SUBCOMMANDS: | |||
246 | }; | 280 | }; |
247 | Ok(command) | 281 | Ok(command) |
248 | } | 282 | } |
249 | |||
250 | fn run(self) -> Result<()> { | ||
251 | match self { | ||
252 | Command::Parse { no_dump } => { | ||
253 | let _p = profile("parsing"); | ||
254 | let file = file()?; | ||
255 | if !no_dump { | ||
256 | println!("{:#?}", file.syntax()); | ||
257 | } | ||
258 | std::mem::forget(file); | ||
259 | } | ||
260 | Command::Symbols => { | ||
261 | let file = file()?; | ||
262 | for s in file_structure(&file) { | ||
263 | println!("{:?}", s); | ||
264 | } | ||
265 | } | ||
266 | Command::Highlight { rainbow } => { | ||
267 | let (analysis, file_id) = Analysis::from_single_file(read_stdin()?); | ||
268 | let html = analysis.highlight_as_html(file_id, rainbow).unwrap(); | ||
269 | println!("{}", html); | ||
270 | } | ||
271 | Command::Stats { verbosity, randomize, memory_usage, only, with_deps, path } => { | ||
272 | analysis_stats::run( | ||
273 | verbosity, | ||
274 | memory_usage, | ||
275 | path.as_ref(), | ||
276 | only.as_ref().map(String::as_ref), | ||
277 | with_deps, | ||
278 | randomize, | ||
279 | )?; | ||
280 | } | ||
281 | Command::Bench { verbose, path, op } => { | ||
282 | analysis_bench::run(verbose, path.as_ref(), op)?; | ||
283 | } | ||
284 | Command::HelpPrinted => (), | ||
285 | } | ||
286 | Ok(()) | ||
287 | } | ||
288 | } | 283 | } |
289 | 284 | ||
290 | fn handle_extra_flags(e: pico_args::Error) -> Result<()> { | 285 | fn handle_extra_flags(e: pico_args::Error) -> Result<()> { |