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

if (PHP_SAPI !== 'cli') {
    return;
}

$classloader = require_once __DIR__ . '/../vendor/autoload.php';

use Drupal\Core\Command\QuickStartCommand;
use Drupal\Core\Command\InstallCommand;
use Drupal\Core\Command\ServerCommand;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\ArrayInput;

if (function_exists('ini_set')) {
    // Due the number of imports, we need at least 256M of memory.
    @ini_set('memory_limit', '256M');
}

$application = new Application('drupal', \Drupal::VERSION);
$application->add(new QuickStartCommand());
$application->add(new InstallCommand($classloader));
$application->add(new ServerCommand($classloader));
$application->setDefaultCommand('quick-start');

// Provide default input arguments for the quick-start command.
if (count($_SERVER['argv']) === 1) {
    $arguments = [
        'command' => 'quick-start',
        'install-profile' => 'commerce_kickstart',
        '--site-name' => 'Drupal Commerce Demo',
        '--no-interaction' => TRUE,
    ];
    $application->run(new ArrayInput($arguments));
}
else {
    $application->run();
}
