diff options
| -rw-r--r-- | crates/mozart-core/src/http.rs | 3 | ||||
| -rw-r--r-- | crates/mozart-core/src/lib.rs | 2 | ||||
| -rw-r--r-- | crates/mozart/src/commands/about.rs | 6 | ||||
| -rw-r--r-- | crates/mozart/src/commands/diagnose.rs | 4 | ||||
| -rw-r--r-- | crates/mozart/src/commands/self_update.rs | 9 | ||||
| -rw-r--r-- | crates/mozart/src/main.rs | 3 |
6 files changed, 14 insertions, 13 deletions
diff --git a/crates/mozart-core/src/http.rs b/crates/mozart-core/src/http.rs index 7d3de8e..907b6a7 100644 --- a/crates/mozart-core/src/http.rs +++ b/crates/mozart-core/src/http.rs @@ -1,3 +1,4 @@ +use crate::MOZART_VERSION; use std::path::{Path, PathBuf}; use std::sync::OnceLock; @@ -9,7 +10,7 @@ use anyhow::{Context, Result, anyhow, bail}; pub fn user_agent() -> String { format!( "Mozart/{} ({}; {})", - env!("CARGO_PKG_VERSION"), + MOZART_VERSION, std::env::consts::OS, std::env::consts::ARCH, ) diff --git a/crates/mozart-core/src/lib.rs b/crates/mozart-core/src/lib.rs index 5383d9a..bc0da53 100644 --- a/crates/mozart-core/src/lib.rs +++ b/crates/mozart-core/src/lib.rs @@ -10,3 +10,5 @@ pub mod wildcard; pub use mozart_console_macros::console_format; pub use wildcard::matches_wildcard; + +pub const MOZART_VERSION: &str = env!("CARGO_PKG_VERSION"); diff --git a/crates/mozart/src/commands/about.rs b/crates/mozart/src/commands/about.rs index 9c58db3..a8566d1 100644 --- a/crates/mozart/src/commands/about.rs +++ b/crates/mozart/src/commands/about.rs @@ -1,4 +1,5 @@ use clap::Args; +use mozart_core::MOZART_VERSION; use mozart_core::console; use mozart_core::console_format; @@ -10,9 +11,10 @@ pub async fn execute( _cli: &super::Cli, console: &console::Console, ) -> anyhow::Result<()> { - let version = env!("CARGO_PKG_VERSION"); console.write_stdout( - &console_format!("<info>Mozart - Dependency Manager for PHP - version {version}</info>"), + &console_format!( + "<info>Mozart - Dependency Manager for PHP - version {MOZART_VERSION}</info>", + ), console::Verbosity::Normal, ); console.write_stdout( diff --git a/crates/mozart/src/commands/diagnose.rs b/crates/mozart/src/commands/diagnose.rs index 2320ddc..54296ce 100644 --- a/crates/mozart/src/commands/diagnose.rs +++ b/crates/mozart/src/commands/diagnose.rs @@ -1,5 +1,6 @@ use clap::Args; use colored::Colorize; +use mozart_core::MOZART_VERSION; use mozart_core::console::{Console, Verbosity}; use std::path::{Path, PathBuf}; @@ -80,8 +81,7 @@ fn print_info_line(result: &CheckResult, console: &Console) { /// Check 1: Mozart version info (informational). fn check_version() -> CheckResult { - let version = env!("CARGO_PKG_VERSION"); - CheckResult::Info(format!("Mozart version {version}")) + CheckResult::Info(format!("Mozart version {MOZART_VERSION}")) } /// Check 2 & 3: HTTP/HTTPS connectivity to Packagist. diff --git a/crates/mozart/src/commands/self_update.rs b/crates/mozart/src/commands/self_update.rs index 2c7c59b..401d15a 100644 --- a/crates/mozart/src/commands/self_update.rs +++ b/crates/mozart/src/commands/self_update.rs @@ -1,4 +1,5 @@ use clap::Args; +use mozart_core::MOZART_VERSION; use mozart_core::console::Verbosity; use mozart_core::console_format; use std::io::Write; @@ -91,12 +92,6 @@ fn get_data_dir() -> anyhow::Result<PathBuf> { .join("mozart")) } -// ─── Version helpers ────────────────────────────────────────────────────────── - -fn get_current_version() -> &'static str { - env!("CARGO_PKG_VERSION") -} - /// Returns the platform-specific binary asset name for the current build target. /// /// Examples: `mozart-linux-x86_64`, `mozart-macos-aarch64`, `mozart-windows-x86_64.exe` @@ -286,7 +281,7 @@ async fn update( data_dir: &Path, console: &mozart_core::console::Console, ) -> anyhow::Result<()> { - let current_version = get_current_version(); + let current_version = MOZART_VERSION; let channel = effective_channel(args.preview); // Fetch releases diff --git a/crates/mozart/src/main.rs b/crates/mozart/src/main.rs index 8201d87..35f8485 100644 --- a/crates/mozart/src/main.rs +++ b/crates/mozart/src/main.rs @@ -1,5 +1,6 @@ use clap::Parser; use mozart::commands; +use mozart_core::MOZART_VERSION; use mozart_core::exit_code; use tracing_subscriber::{EnvFilter, fmt, prelude::*}; @@ -48,7 +49,7 @@ async fn main() { "{}", mozart_core::console_format!( "<info>Mozart</info> version <comment>{}</comment> {}", - env!("CARGO_PKG_VERSION"), + MOZART_VERSION, build_date ) ); |
