<?php

namespace App\Console\Commands\Addon;

use App\Core\Addon\AddonManager;
use Illuminate\Console\Command;

class AddonDeactivateCommand extends Command
{
    protected $signature = 'addon:deactivate {name}';
    protected $description = 'Deactivate an addon module (data preserved)';

    public function handle(AddonManager $manager): int
    {
        $manager->discover();
        try {
            $manager->deactivate($this->argument('name'));
            $this->info('Deactivated.');
            return self::SUCCESS;
        } catch (\Throwable $e) {
            $this->error($e->getMessage());
            return self::FAILURE;
        }
    }
}
