diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-02-22 23:28:29 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-02-22 23:28:29 +0900 |
| commit | 6df59c5e154c2f587de743e675833f5157988b9b (patch) | |
| tree | bfdd36b8f5ffd29e27b8f8464033d76dedbb7214 /crates/mozart/src/main.rs | |
| parent | 9acffe293fdf05fcaf72fb941a13912f31ddfbf8 (diff) | |
| download | php-mozart-6df59c5e154c2f587de743e675833f5157988b9b.tar.gz php-mozart-6df59c5e154c2f587de743e675833f5157988b9b.tar.zst php-mozart-6df59c5e154c2f587de743e675833f5157988b9b.zip | |
feat(cli): match Composer's --version output format
Replace clap's built-in --version with custom handler that outputs
Composer-compatible version info: Mozart version line, PHP version
with binary path, and diagnose hint. Add detect_php_version_and_binary()
to mozart-core platform module.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'crates/mozart/src/main.rs')
| -rw-r--r-- | crates/mozart/src/main.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/crates/mozart/src/main.rs b/crates/mozart/src/main.rs index ed7c4ad..8201d87 100644 --- a/crates/mozart/src/main.rs +++ b/crates/mozart/src/main.rs @@ -40,6 +40,41 @@ fn init_tracing(profile: bool, verbose: u8, quiet: bool) { #[tokio::main] async fn main() { let cli = commands::Cli::parse(); + + if cli.version { + let build_date = option_env!("MOZART_BUILD_DATE").unwrap_or("source"); + // Line 1 (stdout): getLongVersion() equivalent + println!( + "{}", + mozart_core::console_format!( + "<info>Mozart</info> version <comment>{}</comment> {}", + env!("CARGO_PKG_VERSION"), + build_date + ) + ); + // Line 2 (stderr): PHP version + binary path (matches Composer's output) + let (php_version, php_binary) = mozart_core::platform::detect_php_version_and_binary() + .unwrap_or_else(|| ("not found".into(), "php".into())); + eprintln!( + "{}", + mozart_core::console_format!( + "<info>PHP</info> version <comment>{}</comment> ({})", + php_version, + php_binary + ) + ); + // Line 3 (stderr): diagnose hint + eprintln!("Run the \"diagnose\" command to get more detailed diagnostics output."); + return; + } + + let Some(ref _cmd) = cli.command else { + use clap::CommandFactory; + commands::Cli::command().print_help().ok(); + println!(); + return; + }; + init_tracing(cli.profile, cli.verbose, cli.quiet); match commands::execute(&cli).await { Ok(()) => {} |
