diff options
author | Aleksey Kladov <[email protected]> | 2020-02-17 18:03:03 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-02-17 18:03:03 +0000 |
commit | 659b0e73cfd9ef7755d032f90622a08576f1d86d (patch) | |
tree | 238a2cb3e021502608d357785ebbe3b21f94573f /crates/ra_lsp_server/src/main.rs | |
parent | 2d1b3da5fb69d932c65884a361ec10d81e8a51d8 (diff) |
Merge cli and ra_lsp_server
Diffstat (limited to 'crates/ra_lsp_server/src/main.rs')
-rw-r--r-- | crates/ra_lsp_server/src/main.rs | 46 |
1 files changed, 29 insertions, 17 deletions
diff --git a/crates/ra_lsp_server/src/main.rs b/crates/ra_lsp_server/src/main.rs index ed2eaabd4..a549e5ff1 100644 --- a/crates/ra_lsp_server/src/main.rs +++ b/crates/ra_lsp_server/src/main.rs | |||
@@ -1,14 +1,39 @@ | |||
1 | //! `ra_lsp_server` binary | 1 | //! `ra_lsp_server` binary |
2 | mod args; | ||
2 | 3 | ||
3 | use lsp_server::Connection; | 4 | use lsp_server::Connection; |
4 | use ra_lsp_server::{from_json, show_message, Result, ServerConfig}; | 5 | use ra_lsp_server::{cli, from_json, show_message, Result, ServerConfig}; |
5 | use ra_prof; | 6 | use ra_prof; |
6 | 7 | ||
8 | use crate::args::HelpPrinted; | ||
9 | |||
7 | fn main() -> Result<()> { | 10 | fn main() -> Result<()> { |
8 | setup_logging()?; | 11 | setup_logging()?; |
9 | match Args::parse()? { | 12 | let args = match args::Args::parse()? { |
10 | Args::Version => println!("rust-analyzer {}", env!("REV")), | 13 | Ok(it) => it, |
11 | Args::Run => run_server()?, | 14 | Err(HelpPrinted) => return Ok(()), |
15 | }; | ||
16 | match args.command { | ||
17 | args::Command::Parse { no_dump } => cli::parse(no_dump)?, | ||
18 | args::Command::Symbols => cli::symbols()?, | ||
19 | args::Command::Highlight { rainbow } => cli::highlight(rainbow)?, | ||
20 | args::Command::Stats { randomize, memory_usage, only, with_deps, path } => { | ||
21 | cli::analysis_stats( | ||
22 | args.verbosity, | ||
23 | memory_usage, | ||
24 | path.as_ref(), | ||
25 | only.as_ref().map(String::as_ref), | ||
26 | with_deps, | ||
27 | randomize, | ||
28 | )? | ||
29 | } | ||
30 | |||
31 | args::Command::Bench { path, what } => { | ||
32 | cli::analysis_bench(args.verbosity, path.as_ref(), what)? | ||
33 | } | ||
34 | |||
35 | args::Command::RunServer => run_server()?, | ||
36 | args::Command::Version => println!("rust-analyzer {}", env!("REV")), | ||
12 | } | 37 | } |
13 | Ok(()) | 38 | Ok(()) |
14 | } | 39 | } |
@@ -20,19 +45,6 @@ fn setup_logging() -> Result<()> { | |||
20 | Ok(()) | 45 | Ok(()) |
21 | } | 46 | } |
22 | 47 | ||
23 | enum Args { | ||
24 | Version, | ||
25 | Run, | ||
26 | } | ||
27 | |||
28 | impl Args { | ||
29 | fn parse() -> Result<Args> { | ||
30 | let res = | ||
31 | if std::env::args().any(|it| it == "--version") { Args::Version } else { Args::Run }; | ||
32 | Ok(res) | ||
33 | } | ||
34 | } | ||
35 | |||
36 | fn run_server() -> Result<()> { | 48 | fn run_server() -> Result<()> { |
37 | log::info!("lifecycle: server started"); | 49 | log::info!("lifecycle: server started"); |
38 | 50 | ||