Skip to content

Commit 2a38a9e

Browse files
committed
add --version arg to vx
Signed-off-by: Baris Palaska <[email protected]>
1 parent 3f2eab7 commit 2a38a9e

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

vortex-tui/build.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
// SPDX-FileCopyrightText: Copyright the Vortex contributors
3+
4+
fn main() {
5+
// Rerun if git HEAD changes
6+
println!("cargo::rerun-if-changed=../.git/HEAD");
7+
println!("cargo::rerun-if-changed=../.git/refs/tags");
8+
9+
// Try to get version from git describe
10+
if let Ok(output) = std::process::Command::new("git")
11+
.args(["describe", "--tags", "--always"])
12+
.output()
13+
&& output.status.success()
14+
{
15+
let version = String::from_utf8_lossy(&output.stdout);
16+
println!("cargo::rustc-env=VX_VERSION={}", version.trim());
17+
}
18+
}

vortex-tui/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use vortex::session::VortexSession;
2323
use crate::inspect::InspectArgs;
2424

2525
#[derive(clap::Parser)]
26+
#[command(version = option_env!("VX_VERSION").unwrap_or(env!("CARGO_PKG_VERSION")))]
2627
struct Cli {
2728
#[clap(subcommand)]
2829
command: Commands,

0 commit comments

Comments
 (0)