fix(cli): proper version in vault info

feat/vault-scan-modes
Tomáš Mládek 2023-10-22 21:18:00 +02:00
parent c15052656a
commit 86c8921fdd
3 changed files with 7 additions and 12 deletions

View File

@ -36,3 +36,7 @@ lazy_static! {
.build()
.unwrap();
}
pub fn get_version() -> &'static str {
option_env!("UPEND_VERSION").unwrap_or("unknown")
}

View File

@ -179,7 +179,7 @@ struct ServeArgs {
#[actix_web::main]
async fn main() -> Result<()> {
let command = Cli::command().version(option_env!("UPEND_VERSION").unwrap_or("unknown"));
let command = Cli::command().version(crate::common::get_version());
let args = Cli::from_arg_matches(&command.get_matches())?;
tracing_subscriber::fmt()

View File

@ -832,7 +832,8 @@ pub async fn get_info(state: web::Data<State>) -> Result<HttpResponse, Error> {
"name": state.config.vault_name,
// "location": &*state.store.path,
"version": format!(
"{} / {} / {}",
"{} (base: {}, db: {}, cli: {})",
crate::common::get_version(),
upend_base::common::build::PKG_VERSION,
upend_db::common::build::PKG_VERSION,
build::PKG_VERSION
@ -970,21 +971,11 @@ mod tests {
#[derive(Deserialize)]
struct VaultInfo {
name: Option<String>,
version: String,
desktop: bool,
}
let info: VaultInfo = actix_web::test::call_and_read_body_json(&app, req).await;
assert_eq!(info.name, Some("TEST VAULT".to_string()));
assert_eq!(
info.version,
format!(
"{} / {} / {}",
upend_base::common::build::PKG_VERSION,
upend_db::common::build::PKG_VERSION,
build::PKG_VERSION
)
);
assert!(!info.desktop);
}