use clap::Args; use colored::Colorize; use mozart_core::MOZART_VERSION; use mozart_core::composer::Composer; use mozart_core::config::Config; use mozart_core::config_validator::{ValidatorOptions, validate_manifest}; use mozart_core::console::Console; use mozart_core::console_writeln; use mozart_core::factory::create_config; use mozart_core::http::HttpDownloader; use std::borrow::Cow; use std::path::Path; #[derive(Args)] pub struct DiagnoseArgs {} /// Result of a single check, mirroring the `string|true|string[]|\Exception` /// shape of `Composer\Command\DiagnoseCommand`'s private `checkX` methods. enum CheckResult { /// `OK` with optional detail string. Equivalent to PHP `true`. Ok(Option), /// `WARNING` + message lines. Warning(Vec), /// `FAIL` + message lines. Fail(Vec), /// `SKIP` + reason. Composer emits this inline for the /// `allow_url_fopen` / `COMPOSER_DISABLE_NETWORK` cases via the same /// `outputResult` path. Skip(String), } impl CheckResult { fn ok() -> Self { CheckResult::Ok(None) } fn ok_with(detail: impl Into) -> Self { CheckResult::Ok(Some(detail.into())) } fn warn(msg: impl Into) -> Self { CheckResult::Warning(vec![msg.into()]) } fn fail(msg: impl Into) -> Self { CheckResult::Fail(vec![msg.into()]) } } /// Mirror of `DiagnoseCommand::outputResult`. Writes the leading /// `Checking