<?php

namespace kernel\console\controllers;

use kernel\App;
use kernel\console\ConsoleController;
use kernel\helpers\Debug;

class MainController extends ConsoleController
{

    public function indexAction(): void
    {
        $this->out->r("Привет", "green");
    }

    public function actionHelp(): void
    {
        $routs = App::$collector->getData()->getStaticRoutes();
        foreach ($routs as $rout => $data){
            $additionalInfo = $data['GET'][3];
            if (isset($additionalInfo['description']) and $additionalInfo['type'] === "console"){
                $this->out->inLine($rout . " - ", "green");
                $this->out->inLine($additionalInfo['description'], 'yellow');
                $this->out->r("");
                if (isset($additionalInfo['params'])){
                    foreach ($additionalInfo['params'] as $key => $param){
                        $this->out->inLine($key . " - ", "green");
                        $this->out->inLine($param, 'yellow');
                        $this->out->r("");
                    }
                }
                $this->out->r("");
            }
        }
    }

}