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

$rootDir = getcwd();

switch (true) {
    case (file_exists(__DIR__ . '/../vendor/autoload.php')):
        // Called from local git clone.
        require __DIR__ . '/../vendor/autoload.php';
        break;

    case (file_exists(__DIR__ . '/../../../autoload.php')):
        // Called from your project's vendor dir.
        require __DIR__ . '/../../../autoload.php';
        break;

    case (file_exists($rootDir . '/vendor/autoload.php')):
        // Try to fix symlinked script calling.
        require $rootDir . '/vendor/autoload.php';
        break;

    default:
        die(
            'You need to set up the project dependencies using the following commands:' . PHP_EOL .
            'curl -s http://getcomposer.org/installer | php' . PHP_EOL .
            'php composer.phar install' . PHP_EOL
        );
}

use DrupalInstallCli\Console\Application;
use DrupalInstallCli\Command\DrushSiteInstallCommand;
use Composer\Console\Application as ComposerApplication;

$command = new DrushSiteInstallCommand();

$app = new Application($rootDir, 'PHP client library for installing Drupal sites from CLI');
$app->add($command);
$app->run();
