diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-02-21 23:38:32 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-02-21 23:38:32 +0900 |
| commit | 52310761f67220c9c075cd847205825a720035ee (patch) | |
| tree | 0528fc94aea7853e41313e19964d74a958dae9c9 /crates/mozart/src/commands.rs | |
| parent | 92da9e37c68beb180e45e550fba5acd7d28dca27 (diff) | |
| download | php-mozart-52310761f67220c9c075cd847205825a720035ee.tar.gz php-mozart-52310761f67220c9c075cd847205825a720035ee.tar.zst php-mozart-52310761f67220c9c075cd847205825a720035ee.zip | |
feat(console): add structured error handling, verbosity, and suggestions
Implement Phase 7.2 error handling & UX infrastructure:
- Add exit_code module with MozartError, bail()/bail_silent() helpers,
and Composer-compatible exit code constants (0-5, 100)
- Redesign Console struct with Verbosity enum (Quiet/Normal/Verbose/
VeryVerbose/Debug), ANSI auto-detection via IsTerminal, and
verbosity-gated output methods (info/verbose/debug/error)
- Thread Console through all 33 command execute() signatures
- Replace all std::process::exit() calls with structured MozartError
returns handled in main()
- Migrate eprintln\! status messages to console.info() for quiet-mode
suppression
- Add suggest module with Levenshtein distance and "Did you mean?"
formatting for future package name suggestions
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'crates/mozart/src/commands.rs')
| -rw-r--r-- | crates/mozart/src/commands.rs | 65 |
1 files changed, 33 insertions, 32 deletions
diff --git a/crates/mozart/src/commands.rs b/crates/mozart/src/commands.rs index 83ff7b8..694b4e1 100644 --- a/crates/mozart/src/commands.rs +++ b/crates/mozart/src/commands.rs @@ -194,38 +194,39 @@ pub enum Commands { } pub fn execute(cli: &Cli) -> anyhow::Result<()> { + let console = crate::console::Console::from_cli(cli); match &cli.command { - Commands::About(args) => about::execute(args, cli), - Commands::Archive(args) => archive::execute(args, cli), - Commands::Audit(args) => audit::execute(args, cli), - Commands::Browse(args) => browse::execute(args, cli), - Commands::Bump(args) => bump::execute(args, cli), - Commands::CheckPlatformReqs(args) => check_platform_reqs::execute(args, cli), - Commands::ClearCache(args) => clear_cache::execute(args, cli), - Commands::Config(args) => config::execute(args, cli), - Commands::CreateProject(args) => create_project::execute(args, cli), - Commands::Depends(args) => depends::execute(args, cli), - Commands::Diagnose(args) => diagnose::execute(args, cli), - Commands::DumpAutoload(args) => dump_autoload::execute(args, cli), - Commands::Exec(args) => exec::execute(args, cli), - Commands::Fund(args) => fund::execute(args, cli), - Commands::Global(args) => global::execute(args, cli), - Commands::Init(args) => init::execute(args, cli), - Commands::Install(args) => install::execute(args, cli), - Commands::Licenses(args) => licenses::execute(args, cli), - Commands::Outdated(args) => outdated::execute(args, cli), - Commands::Prohibits(args) => prohibits::execute(args, cli), - Commands::Reinstall(args) => reinstall::execute(args, cli), - Commands::Remove(args) => remove::execute(args, cli), - Commands::Repository(args) => repository::execute(args, cli), - Commands::Require(args) => require::execute(args, cli), - Commands::RunScript(args) => run_script::execute(args, cli), - Commands::Search(args) => search::execute(args, cli), - Commands::SelfUpdate(args) => self_update::execute(args, cli), - Commands::Show(args) => show::execute(args, cli), - Commands::Status(args) => status::execute(args, cli), - Commands::Suggests(args) => suggests::execute(args, cli), - Commands::Update(args) => update::execute(args, cli), - Commands::Validate(args) => validate::execute(args, cli), + Commands::About(args) => about::execute(args, cli, &console), + Commands::Archive(args) => archive::execute(args, cli, &console), + Commands::Audit(args) => audit::execute(args, cli, &console), + Commands::Browse(args) => browse::execute(args, cli, &console), + Commands::Bump(args) => bump::execute(args, cli, &console), + Commands::CheckPlatformReqs(args) => check_platform_reqs::execute(args, cli, &console), + Commands::ClearCache(args) => clear_cache::execute(args, cli, &console), + Commands::Config(args) => config::execute(args, cli, &console), + Commands::CreateProject(args) => create_project::execute(args, cli, &console), + Commands::Depends(args) => depends::execute(args, cli, &console), + Commands::Diagnose(args) => diagnose::execute(args, cli, &console), + Commands::DumpAutoload(args) => dump_autoload::execute(args, cli, &console), + Commands::Exec(args) => exec::execute(args, cli, &console), + Commands::Fund(args) => fund::execute(args, cli, &console), + Commands::Global(args) => global::execute(args, cli, &console), + Commands::Init(args) => init::execute(args, cli, &console), + Commands::Install(args) => install::execute(args, cli, &console), + Commands::Licenses(args) => licenses::execute(args, cli, &console), + Commands::Outdated(args) => outdated::execute(args, cli, &console), + Commands::Prohibits(args) => prohibits::execute(args, cli, &console), + Commands::Reinstall(args) => reinstall::execute(args, cli, &console), + Commands::Remove(args) => remove::execute(args, cli, &console), + Commands::Repository(args) => repository::execute(args, cli, &console), + Commands::Require(args) => require::execute(args, cli, &console), + Commands::RunScript(args) => run_script::execute(args, cli, &console), + Commands::Search(args) => search::execute(args, cli, &console), + Commands::SelfUpdate(args) => self_update::execute(args, cli, &console), + Commands::Show(args) => show::execute(args, cli, &console), + Commands::Status(args) => status::execute(args, cli, &console), + Commands::Suggests(args) => suggests::execute(args, cli, &console), + Commands::Update(args) => update::execute(args, cli, &console), + Commands::Validate(args) => validate::execute(args, cli, &console), } } |
