#!/usr/bin/env php
<?php

if (\PHP_VERSION_ID < 70100) {
    echo "Phint requires PHP7.1 or newer\n";

    exit(1);
}

if (\Phar::running() && !\extension_loaded('zlib')) {
    echo "Phint.phar requires 'zlib' extension\n(OR you can compile phar with `compression: NONE` in box.json)\n";

    exit(1);
}

if (\file_exists(__DIR__ . '/../../../autoload.php')) {
    require __DIR__ . '/../../../autoload.php';
} elseif (\file_exists(__DIR__ . '/../../autoload.php')) {
    require __DIR__ . '/../../autoload.php';
} else {
    require __DIR__ . '/../vendor/autoload.php';
}

$logo = "
  _____  _     _       _
 |  __ \| |   (_)     | |
 | |__) | |__  _ _ __ | |_
 |  ___/| '_ \| | '_ \| __|
 | |    | | | | | | | | |_
 |_|    |_| |_|_|_| |_|\__|

PHP Project Scaffolding Tool
============================
";

$app = new Ahc\Cli\Application(
    'Phint',
    \trim(\file_get_contents(__DIR__ . '/../VERSION'))
);

// Add commands and their aliases
$app->add(new Ahc\Phint\Console\InitCommand,   'i');
$app->add(new Ahc\Phint\Console\UpdateCommand, 'u');
$app->add(new Ahc\Phint\Console\TestCommand,   't');
$app->add(new Ahc\Phint\Console\DocsCommand,   'd');
$app->add(new Ahc\Phint\Console\ExportCommand, 'e');

$app->logo($logo)->handle($_SERVER['argv']);
