<?php

namespace App\Commands;

use App\Services\Command;
use App\Services\Docker;
use Illuminate\Support\Facades\Process;

class Cli extends Command
{
    protected $signature = 'cli {args?* : Arguments}';
    protected $description = 'Run a specific wp-cli script';

    public function handle(): void
    {

        $argsString = implode(' ', $this->argument('args'));
        $cliCommand = Docker::exec(command: 'wp ' .$argsString . ' --allow-root');

        Process::forever()->tty()->run($cliCommand, function (string $type, string $output) {
            echo $output;
        });


    }
}
