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

if (file_exists(__DIR__ . '/vendor/autoload.php')) {
    define('COMPOSER_BINARY_DIR', __DIR__ . "/vendor/bin/");
    require_once __DIR__ . '/vendor/autoload.php';
} elseif (file_exists(__DIR__ . '/../../autoload.php')) {
    define('COMPOSER_BINARY_DIR', __DIR__ . "/../../bin/");
    require_once __DIR__ . '/../../autoload.php';
}

require_once __DIR__ . "/RoboFile.php";

$isNotToolsCommand = !(count($argv) >= 2 && $argv[1] == 'tools');
if ($isNotToolsCommand) {
    // add robo command between the application name and the arguments
    array_splice($argv, 1, 0, 'ci');
}

// IO
$input = new \Symfony\Component\Console\Input\ArgvInput($argv);
$output = new \Symfony\Component\Console\Output\ConsoleOutput();
\Robo\Config::setOutput($output);

// run robo
$robo = new \Robo\Runner();
$qa = $robo->createApplication(RoboFile::class);
$qa->run($input, $output);
