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

if (strpos(__DIR__, 'vendor') === false) {
    require __DIR__ . '/../vendor/autoload.php';
} else {
    // assume vendor to be on include_path if installed
    require 'vendor/autoload.php';
}

use Graviton\Deployment\Command\CloudFoundry\AuthCommand;
use Graviton\Deployment\Command\CloudFoundry\CheckApplicationCommand;
use Graviton\Deployment\Command\CloudFoundry\CreateServiceCommand;
use Graviton\Deployment\Command\CloudFoundry\DeployCommand;
use Graviton\Deployment\Command\CloudFoundry\LoginCommand;
use Graviton\Deployment\Command\CloudFoundry\LogoutCommand;
use Graviton\Deployment\Configuration;
use Graviton\Deployment\Deployment;
use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Console\Application;
use Symfony\Component\Process\ProcessBuilder;

$configuration = new Configuration(new Processor(), new FileLocator(getcwd(). '/app/config'));
$deploymentHandler = new Deployment(new ProcessBuilder());

$application = new Application();
$application->add(new CheckApplicationCommand($configuration));
$application->add(new DeployCommand($deploymentHandler, $configuration));
$application->run();
