Skip to content

Commit 27c6f44

Browse files
committed
feat!: print fallback include path in --version
1 parent 66d7762 commit 27c6f44

File tree

3 files changed

+50
-2
lines changed

3 files changed

+50
-2
lines changed

Cargo.lock

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ serde_json = "1.0"
3030
basic-toml = "0.1"
3131
pkg-config = "0.3"
3232
clap = { version = "4.5", features = ["derive"] }
33+
const_format = "0.2"
3334

3435
[dev-dependencies]
3536
insta = { version = "1.43", features = ["yaml", "redactions"] }

src/main.rs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use async_lsp::panic::CatchUnwindLayer;
66
use async_lsp::server::LifecycleLayer;
77
use async_lsp::tracing::TracingLayer;
88
use clap::Parser;
9+
use const_format::concatcp;
910
use server::{ProtoLanguageServer, TickEvent};
1011
use tower::ServiceBuilder;
1112
use tracing::Level;
@@ -25,13 +26,32 @@ mod workspace;
2526

2627
/// Language server for proto3 files
2728
#[derive(Parser, Debug)]
28-
#[command(author, version, about, long_about = None, ignore_errors(true))]
29+
#[command(
30+
author,
31+
version = concatcp!(
32+
env!("CARGO_PKG_VERSION"),
33+
"\n",
34+
BUILD_INFO
35+
),
36+
about,
37+
long_about = None,
38+
ignore_errors(true)
39+
)]
2940
struct Cli {
3041
/// Include paths for proto files
3142
#[arg(short, long, value_delimiter = ',')]
3243
include_paths: Option<Vec<String>>,
3344
}
3445

46+
const FALLBACK_INCLUDE_PATH: Option<&str> = option_env!("FALLBACK_INCLUDE_PATH");
47+
const BUILD_INFO: &str = concatcp!(
48+
"fallback include path: ",
49+
match FALLBACK_INCLUDE_PATH {
50+
Some(path) => path,
51+
None => "not set",
52+
}
53+
);
54+
3555
#[tokio::main(flavor = "current_thread")]
3656
async fn main() {
3757
let cli = Cli::parse();
@@ -48,7 +68,7 @@ async fn main() {
4868
.with_writer(file_appender.0)
4969
.init();
5070

51-
let fallback_include_path = option_env!("FALLBACK_INCLUDE_PATH").map(Into::into);
71+
let fallback_include_path = FALLBACK_INCLUDE_PATH.map(Into::into);
5272

5373
tracing::info!("server version: {}", env!("CARGO_PKG_VERSION"));
5474
let (server, _) = async_lsp::MainLoop::new_server(|client| {

0 commit comments

Comments
 (0)