aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-12-09 15:12:23 +0000
committerGitHub <[email protected]>2019-12-09 15:12:23 +0000
commit442ab3a34dfaf41bc3852acb9db20e0687d20b0c (patch)
tree6e851cef5afa7c8eb1b2536c93924ca350d9b9c7 /crates/ra_lsp_server
parent7819aa8862a01973853ca622df264920e54f45ce (diff)
parent5a012fb9fd87404515033b2a5e025f2b7ec44b29 (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')
-rw-r--r--crates/ra_lsp_server/build.rs15
-rw-r--r--crates/ra_lsp_server/src/main.rs18
2 files changed, 32 insertions, 1 deletions
diff --git a/crates/ra_lsp_server/build.rs b/crates/ra_lsp_server/build.rs
new file mode 100644
index 000000000..05f9772c0
--- /dev/null
+++ b/crates/ra_lsp_server/build.rs
@@ -0,0 +1,15 @@
1//! Just embed git-hash to `--version`
2
3use std::process::Command;
4
5fn main() {
6 let rev = rev().unwrap_or_else(|| "???????".to_string());
7 println!("cargo:rustc-env=REV={}", rev)
8}
9
10fn rev() -> Option<String> {
11 let output = Command::new("git").args(&["rev-parse", "HEAD"]).output().ok()?;
12 let stdout = String::from_utf8(output.stdout).ok()?;
13 let short_hash = stdout.get(0..7)?;
14 Some(short_hash.to_owned())
15}
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
7fn main() -> Result<()> { 7fn 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
28enum Args {
29 Version,
30 Run,
31}
32
33impl 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
25fn run_server() -> Result<()> { 41fn run_server() -> Result<()> {
26 log::info!("lifecycle: server started"); 42 log::info!("lifecycle: server started");
27 43