diff --git a/composer.json b/composer.json
index d94ede2..cb8fb3a 100644
--- a/composer.json
+++ b/composer.json
@@ -23,11 +23,13 @@
"symfony-cmf/routing": "1.1.*@alpha",
"easyrdf/easyrdf": "0.8.*",
"phpunit/phpunit": "3.7.*",
- "zendframework/zend-feed": "2.2.*"
+ "zendframework/zend-feed": "2.2.*",
+ "symfony/console": "*"
},
"autoload": {
"psr-0": {
"Drupal\\Core": "core/lib/",
+ "Drupal\\Console": "core/lib/",
"Drupal\\Component": "core/lib/",
"Drupal\\Driver": "drivers/lib/"
},
diff --git a/core/console b/core/console
new file mode 100755
index 0000000..a0fb755
--- /dev/null
+++ b/core/console
@@ -0,0 +1,24 @@
+#!/usr/bin/env php
+addCommands($commands);
+$application->run();
diff --git a/core/lib/Drupal/Console/Command/CacheClearCommand.php b/core/lib/Drupal/Console/Command/CacheClearCommand.php
new file mode 100644
index 0000000..87439e4
--- /dev/null
+++ b/core/lib/Drupal/Console/Command/CacheClearCommand.php
@@ -0,0 +1,35 @@
+setName('cache:clear')
+ ->setDescription('Clear all caches.');
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function execute(InputInterface $input, OutputInterface $output) {
+ if ($this->bootstrap($input, $output)) {
+ $output->writeln('Clearing all caches...');
+ \drupal_flush_all_caches();
+ }
+ }
+
+}
diff --git a/core/lib/Drupal/Console/Command/CommandBootstrapBase.php b/core/lib/Drupal/Console/Command/CommandBootstrapBase.php
new file mode 100644
index 0000000..4e55ccc
--- /dev/null
+++ b/core/lib/Drupal/Console/Command/CommandBootstrapBase.php
@@ -0,0 +1,73 @@
+getOption('environment');
+ // Yes, we have to require_once.
+ require_once __DIR__ . '/../../../../includes/bootstrap.inc';
+ try {
+ // This boot strategy ripped from drupal_handle_request().
+ // This should be about four lines of code, but it's not properly
+ // refactored at the kernel level.
+ drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION);
+
+ $kernel = new DrupalKernel($env, \drupal_classloader(), TRUE);
+ $kernel->boot();
+
+ if (!$request) {
+ // Create a meaningful request object. We shouldn't really need this but
+ // Drupal complains if it's not present.
+ $request = Request::createFromGlobals();
+ }
+ $container = $kernel->getContainer();
+ $container->set('request', $request);
+ $container->get('request_stack')->push($request);
+
+ drupal_bootstrap(DRUPAL_BOOTSTRAP_CODE);
+ return $kernel;
+ }
+ catch (\Exception $e) {
+ $formatter = $this->getHelperSet()->get('formatter');
+ $error_messages = array(
+ 'Insufficient Drupal to proceed.',
+ 'This command requires a bootable Drupal installation.',
+ );
+ $formatted_block = $formatter->formatBlock($error_messages, 'error', TRUE);
+ $output->writeln($formatted_block);
+ }
+ return FALSE;
+ }
+
+}
diff --git a/core/lib/Drupal/Console/Command/DrupalCronCommand.php b/core/lib/Drupal/Console/Command/DrupalCronCommand.php
new file mode 100644
index 0000000..16794d3
--- /dev/null
+++ b/core/lib/Drupal/Console/Command/DrupalCronCommand.php
@@ -0,0 +1,39 @@
+setName('drupal:cron')
+ ->setDescription('Perform a cron run.');
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function execute(InputInterface $input, OutputInterface $output) {
+ $kernel = $this->bootstrap($input, $output);
+ if ($kernel) {
+ $output->writeln('Running cron...');
+ $cron = $kernel->getContainer()->get('cron');
+ $cron->run();
+ $output->writeln('Done.');
+ return;
+ }
+ }
+
+}
diff --git a/core/lib/Drupal/Console/Command/DrupalRequestCommand.php b/core/lib/Drupal/Console/Command/DrupalRequestCommand.php
new file mode 100644
index 0000000..97949ea
--- /dev/null
+++ b/core/lib/Drupal/Console/Command/DrupalRequestCommand.php
@@ -0,0 +1,56 @@
+setName('drupal:request')
+ ->setDescription('Make a request to this Drupal installation.')
+ ->addArgument(
+ 'uri', InputArgument::OPTIONAL, 'URI to request. Wrap in double-quotes if it contains ampersand.', '/'
+ )
+ ->addOption(
+ 'status-only', 's', InputOption::VALUE_NONE, 'Print only the status code.'
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function execute(InputInterface $input, OutputInterface $output) {
+ $uri = $input->getArgument('uri');
+ $request = Request::create($uri, 'GET');
+ $kernel = $this->bootstrap($input, $output, $request);
+ if ($kernel) {
+ $response = $kernel->handle($request)->prepare($request);
+
+ if ($input->getOption('status-only')) {
+ echo $response->getStatusCode() . "\n";
+ return;
+ }
+
+ echo $response->getContent();
+ $kernel->terminate($request, $response);
+ return;
+ }
+ $output->writeln('Unable to bootstrap a Drupal kernel.');
+ }
+
+}
diff --git a/core/lib/Drupal/Console/DrupalApplication.php b/core/lib/Drupal/Console/DrupalApplication.php
new file mode 100644
index 0000000..7a745b4
--- /dev/null
+++ b/core/lib/Drupal/Console/DrupalApplication.php
@@ -0,0 +1,29 @@
+getDefinition()->addOption($env_opt);
+ }
+
+}