File tree Expand file tree Collapse file tree 2 files changed +25
-3
lines changed
cmd/soroban-cli/src/commands Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -2660,7 +2660,12 @@ Read cached action
26602660
26612661Print version information
26622662
2663- ** Usage:** ` stellar version `
2663+ ** Usage:** ` stellar version [OPTIONS] `
2664+
2665+ ###### ** Options:**
2666+
2667+ * ` --only-version ` — Print only the version
2668+ * ` --only-version-major ` — Print only the major version
26642669
26652670
26662671
Original file line number Diff line number Diff line change @@ -3,19 +3,36 @@ use std::fmt::Debug;
33
44#[ derive( Parser , Debug , Clone ) ]
55#[ group( skip) ]
6- pub struct Cmd ;
6+ pub struct Cmd {
7+ /// Print only the version.
8+ #[ arg( long) ]
9+ only_version : bool ,
10+ /// Print only the major version.
11+ #[ arg( long) ]
12+ only_version_major : bool ,
13+ }
714
815impl Cmd {
916 #[ allow( clippy:: unused_self) ]
1017 pub fn run ( & self ) {
11- println ! ( "stellar {}" , long( ) ) ;
18+ if self . only_version {
19+ println ! ( "{}" , pkg( ) ) ;
20+ } else if self . only_version_major {
21+ println ! ( "{}" , major( ) ) ;
22+ } else {
23+ println ! ( "stellar {}" , long( ) ) ;
24+ }
1225 }
1326}
1427
1528pub fn pkg ( ) -> & ' static str {
1629 env ! ( "CARGO_PKG_VERSION" )
1730}
1831
32+ pub fn major ( ) -> & ' static str {
33+ env ! ( "CARGO_PKG_VERSION_MAJOR" )
34+ }
35+
1936pub fn git ( ) -> & ' static str {
2037 env ! ( "GIT_REVISION" )
2138}
You can’t perform that action at this time.
0 commit comments