diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-12-09 15:12:23 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-12-09 15:12:23 +0000 |
commit | 442ab3a34dfaf41bc3852acb9db20e0687d20b0c (patch) | |
tree | 6e851cef5afa7c8eb1b2536c93924ca350d9b9c7 /crates/ra_lsp_server/src/main.rs | |
parent | 7819aa8862a01973853ca622df264920e54f45ce (diff) | |
parent | 5a012fb9fd87404515033b2a5e025f2b7ec44b29 (diff) |
Merge #2511
2511: Implement `ra_lsp_server --version` r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_lsp_server/src/main.rs')
-rw-r--r-- | crates/ra_lsp_server/src/main.rs | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/crates/ra_lsp_server/src/main.rs b/crates/ra_lsp_server/src/main.rs index 8076a7fa5..cdd925c9f 100644 --- a/crates/ra_lsp_server/src/main.rs +++ b/crates/ra_lsp_server/src/main.rs | |||
@@ -6,7 +6,10 @@ use ra_prof; | |||
6 | 6 | ||
7 | fn main() -> Result<()> { | 7 | fn main() -> Result<()> { |
8 | setup_logging()?; | 8 | setup_logging()?; |
9 | run_server()?; | 9 | match Args::parse()? { |
10 | Args::Version => println!("rust-analyzer {}", env!("REV")), | ||
11 | Args::Run => run_server()?, | ||
12 | } | ||
10 | Ok(()) | 13 | Ok(()) |
11 | } | 14 | } |
12 | 15 | ||
@@ -22,6 +25,19 @@ fn setup_logging() -> Result<()> { | |||
22 | Ok(()) | 25 | Ok(()) |
23 | } | 26 | } |
24 | 27 | ||
28 | enum Args { | ||
29 | Version, | ||
30 | Run, | ||
31 | } | ||
32 | |||
33 | impl Args { | ||
34 | fn parse() -> Result<Args> { | ||
35 | let res = | ||
36 | if std::env::args().any(|it| it == "--version") { Args::Version } else { Args::Run }; | ||
37 | Ok(res) | ||
38 | } | ||
39 | } | ||
40 | |||
25 | fn run_server() -> Result<()> { | 41 | fn run_server() -> Result<()> { |
26 | log::info!("lifecycle: server started"); | 42 | log::info!("lifecycle: server started"); |
27 | 43 | ||