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

define('CLI_ACCOUNTS_SITE', (getenv("PLATFORM_CLI_ACCOUNTS_SITE") ?: "https://marketplace.commerceguys.com"));

// Important: CLI_VERIFY_SSL_CERT must always be true in production.
// We use a reversed environment variable here to account for the crappy behavior of PHP's getenv().
define('CLI_VERIFY_SSL_CERT', (bool) !getenv("PLATFORM_CLI_SKIP_SSL_VERIFY"));

// __DIR__ called in a class will point to the class directory. Saved now it
// ensure there's always a path to the cli root.
define('CLI_ROOT', __DIR__);

if (file_exists(CLI_ROOT . '/vendor/autoload.php')) {
    require CLI_ROOT . '/vendor/autoload.php';
} elseif (file_exists(CLI_ROOT . '/../../autoload.php')) {
    // we are globally installed via Composer
    require CLI_ROOT . '/../../autoload.php';
} else {
    echo "Composer autoload file not found.\n";
    echo "You need to run 'composer install'.\n";
    exit(1);
}

use CommerceGuys\Platform\Cli\Application;
use Symfony\Component\Console\Input\ArgvInput;

$input = new ArgvInput();
$application = new Application();
$application->run($input);
