Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion FULL_HELP_DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2660,7 +2660,12 @@ Read cached action

Print version information

**Usage:** `stellar version`
**Usage:** `stellar version [OPTIONS]`

###### **Options:**

* `--only-version` — Print only the version
* `--only-version-major` — Print only the major version



Expand Down
21 changes: 19 additions & 2 deletions cmd/soroban-cli/src/commands/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,36 @@ use std::fmt::Debug;

#[derive(Parser, Debug, Clone)]
#[group(skip)]
pub struct Cmd;
pub struct Cmd {
/// Print only the version.
#[arg(long)]
only_version: bool,
/// Print only the major version.
#[arg(long)]
only_version_major: bool,
}

impl Cmd {
#[allow(clippy::unused_self)]
pub fn run(&self) {
println!("stellar {}", long());
if self.only_version {
println!("{}", pkg());
} else if self.only_version_major {
println!("{}", major());
} else {
println!("stellar {}", long());
}
}
}

pub fn pkg() -> &'static str {
env!("CARGO_PKG_VERSION")
}

pub fn major() -> &'static str {
env!("CARGO_PKG_VERSION_MAJOR")
}

pub fn git() -> &'static str {
env!("GIT_REVISION")
}
Expand Down