#!/usr/bin/php
<?php

if (php_sapi_name() !== 'cli') {
    exit;
}

require_once __DIR__ . '/vendor/autoload.php';

use App\Core\Application;
use App\Core\Config;
use App\Core\Command_Container;
use App\IO\Output;
use App\IO\Input;
use App\IO\Themes\Alt_Printer;
use App\Core\Command_Request;

// Get any user set config values
$config = Config::load(__DIR__ . '/App/config.ini')->get();

$Command_Request = new Command_Request($argv);
$Command_Container = new Command_Container($config, $Command_Request->process());

$app = Application::load($Command_Container);

$app->set('hello-world', function () {
    $out = new Output(new Alt_Printer);
    $out->message('Hello World');

    if (Input::affirm('Would you like to continue? Y/n')) {
        Output::success('CONTINUE');
    }

    if (Input::warnAffirm('This cannot be undone are you sure? Yes/No', ['Yes', 'No'])) {
        Output::success('warn continue');
    }
});

$app->set('help', function () {
    Output::file(__DIR__ . '/App/Output_Files/test.txt', ['version' => '1.2.3-beta']);
});

$app->set('world', 'App\Commands\Hello\Default_Handler@world');

$app->run();
