diff options
Diffstat (limited to 'crates/rust-analyzer/src/bin/main.rs')
-rw-r--r-- | crates/rust-analyzer/src/bin/main.rs | 51 |
1 files changed, 13 insertions, 38 deletions
diff --git a/crates/rust-analyzer/src/bin/main.rs b/crates/rust-analyzer/src/bin/main.rs index a473c9165..fc7f8b01d 100644 --- a/crates/rust-analyzer/src/bin/main.rs +++ b/crates/rust-analyzer/src/bin/main.rs | |||
@@ -3,7 +3,7 @@ | |||
3 | //! Based on cli flags, either spawns an LSP server, or runs a batch analysis | 3 | //! Based on cli flags, either spawns an LSP server, or runs a batch analysis |
4 | mod args; | 4 | mod args; |
5 | 5 | ||
6 | use std::convert::TryFrom; | 6 | use std::{convert::TryFrom, process}; |
7 | 7 | ||
8 | use lsp_server::Connection; | 8 | use lsp_server::Connection; |
9 | use ra_project_model::ProjectManifest; | 9 | use ra_project_model::ProjectManifest; |
@@ -14,18 +14,20 @@ use rust_analyzer::{ | |||
14 | }; | 14 | }; |
15 | use vfs::AbsPathBuf; | 15 | use vfs::AbsPathBuf; |
16 | 16 | ||
17 | use crate::args::HelpPrinted; | ||
18 | |||
19 | #[cfg(all(feature = "mimalloc"))] | 17 | #[cfg(all(feature = "mimalloc"))] |
20 | #[global_allocator] | 18 | #[global_allocator] |
21 | static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc; | 19 | static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc; |
22 | 20 | ||
23 | fn main() -> Result<()> { | 21 | fn main() { |
22 | if let Err(err) = try_main() { | ||
23 | eprintln!("{}", err); | ||
24 | process::exit(101); | ||
25 | } | ||
26 | } | ||
27 | |||
28 | fn try_main() -> Result<()> { | ||
24 | setup_logging()?; | 29 | setup_logging()?; |
25 | let args = match args::Args::parse()? { | 30 | let args = args::Args::parse()?; |
26 | Ok(it) => it, | ||
27 | Err(HelpPrinted) => return Ok(()), | ||
28 | }; | ||
29 | match args.command { | 31 | match args.command { |
30 | args::Command::RunServer => run_server()?, | 32 | args::Command::RunServer => run_server()?, |
31 | args::Command::ProcMacro => ra_proc_macro_srv::cli::run()?, | 33 | args::Command::ProcMacro => ra_proc_macro_srv::cli::run()?, |
@@ -33,36 +35,8 @@ fn main() -> Result<()> { | |||
33 | args::Command::Parse { no_dump } => cli::parse(no_dump)?, | 35 | args::Command::Parse { no_dump } => cli::parse(no_dump)?, |
34 | args::Command::Symbols => cli::symbols()?, | 36 | args::Command::Symbols => cli::symbols()?, |
35 | args::Command::Highlight { rainbow } => cli::highlight(rainbow)?, | 37 | args::Command::Highlight { rainbow } => cli::highlight(rainbow)?, |
36 | args::Command::Stats { | 38 | args::Command::AnalysisStats(cmd) => cmd.run(args.verbosity)?, |
37 | randomize, | 39 | args::Command::Bench(cmd) => cmd.run(args.verbosity)?, |
38 | parallel, | ||
39 | memory_usage, | ||
40 | only, | ||
41 | with_deps, | ||
42 | path, | ||
43 | load_output_dirs, | ||
44 | with_proc_macro, | ||
45 | } => cli::analysis_stats( | ||
46 | args.verbosity, | ||
47 | memory_usage, | ||
48 | path.as_ref(), | ||
49 | only.as_ref().map(String::as_ref), | ||
50 | with_deps, | ||
51 | randomize, | ||
52 | parallel, | ||
53 | load_output_dirs, | ||
54 | with_proc_macro, | ||
55 | )?, | ||
56 | args::Command::Bench { memory_usage, path, what, load_output_dirs, with_proc_macro } => { | ||
57 | cli::analysis_bench( | ||
58 | args.verbosity, | ||
59 | path.as_ref(), | ||
60 | what, | ||
61 | memory_usage, | ||
62 | load_output_dirs, | ||
63 | with_proc_macro, | ||
64 | )? | ||
65 | } | ||
66 | args::Command::Diagnostics { path, load_output_dirs, with_proc_macro, all } => { | 40 | args::Command::Diagnostics { path, load_output_dirs, with_proc_macro, all } => { |
67 | cli::diagnostics(path.as_ref(), load_output_dirs, with_proc_macro, all)? | 41 | cli::diagnostics(path.as_ref(), load_output_dirs, with_proc_macro, all)? |
68 | } | 42 | } |
@@ -73,6 +47,7 @@ fn main() -> Result<()> { | |||
73 | cli::search_for_patterns(patterns, debug_snippet)?; | 47 | cli::search_for_patterns(patterns, debug_snippet)?; |
74 | } | 48 | } |
75 | args::Command::Version => println!("rust-analyzer {}", env!("REV")), | 49 | args::Command::Version => println!("rust-analyzer {}", env!("REV")), |
50 | args::Command::Help => {} | ||
76 | } | 51 | } |
77 | Ok(()) | 52 | Ok(()) |
78 | } | 53 | } |