soroban_cli/commands/
version.rs

1use clap::Parser;
2use std::fmt::Debug;
3
4#[derive(Parser, Debug, Clone)]
5#[group(skip)]
6pub struct Cmd;
7
8impl Cmd {
9    #[allow(clippy::unused_self)]
10    pub fn run(&self) {
11        println!("stellar {}", long());
12    }
13}
14
15pub fn pkg() -> &'static str {
16    env!("CARGO_PKG_VERSION")
17}
18
19pub fn git() -> &'static str {
20    env!("GIT_REVISION")
21}
22
23pub fn long() -> String {
24    let xdr = stellar_xdr::VERSION;
25    [
26        format!("{} ({})", pkg(), git()),
27        format!(
28            "stellar-xdr {} ({})
29xdr curr ({})",
30            xdr.pkg, xdr.rev, xdr.xdr_curr,
31        ),
32    ]
33    .join("\n")
34}