diff options
Diffstat (limited to 'crates/rust-analyzer/src/bin/main.rs')
-rw-r--r-- | crates/rust-analyzer/src/bin/main.rs | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/crates/rust-analyzer/src/bin/main.rs b/crates/rust-analyzer/src/bin/main.rs index ff8234495..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()?, |
@@ -45,6 +47,7 @@ fn main() -> Result<()> { | |||
45 | cli::search_for_patterns(patterns, debug_snippet)?; | 47 | cli::search_for_patterns(patterns, debug_snippet)?; |
46 | } | 48 | } |
47 | args::Command::Version => println!("rust-analyzer {}", env!("REV")), | 49 | args::Command::Version => println!("rust-analyzer {}", env!("REV")), |
50 | args::Command::Help => {} | ||
48 | } | 51 | } |
49 | Ok(()) | 52 | Ok(()) |
50 | } | 53 | } |