Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make output consistent for all ways to get version #1100

Merged
merged 7 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
12 changes: 9 additions & 3 deletions cmd/soroban-cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::str::FromStr;

use clap::{command, error::ErrorKind, CommandFactory, FromArgMatches, Parser};
use clap::{command, error::ErrorKind, ArgAction, CommandFactory, FromArgMatches, Parser};

pub mod completion;
pub mod config;
Expand Down Expand Up @@ -45,13 +45,19 @@ Full CLI reference: https://github.com/stellar/soroban-tools/tree/main/docs/soro
#[derive(Parser, Debug)]
#[command(
name = "soroban",
version = version::short(),
long_version = version::long(),
about = ABOUT,
version = version::long(),
long_about = ABOUT.to_string() + LONG_ABOUT,
disable_help_subcommand = true,
disable_version_flag = true,
chadoh marked this conversation as resolved.
Show resolved Hide resolved
)]
pub struct Root {
// Supply alternative and common ways to get at the version via a -V and
// --version, but hide it in the help so as not to clutter the help with so
// many ways to get at the version.
#[arg(short = 'V', long, action = ArgAction::Version, hide = true)]
pub version: bool,

#[clap(flatten)]
pub global_args: global::Args,

Expand Down
6 changes: 1 addition & 5 deletions cmd/soroban-cli/src/commands/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,11 @@ impl Cmd {
}
}

pub fn short() -> String {
format!("{} ({GIT_REVISION})", env!("CARGO_PKG_VERSION"))
}

pub fn long() -> String {
let env = soroban_env_host::VERSION;
let xdr = soroban_env_host::VERSION.xdr;
[
short(),
format!("{} ({GIT_REVISION})", env!("CARGO_PKG_VERSION")),
format!("soroban-env {} ({})", env.pkg, env.rev),
format!("soroban-env interface version {}", meta::INTERFACE_VERSION),
format!(
Expand Down
Loading