Add console command to daenerys tool.

This commit is contained in:
Austen McDonald
2016-07-22 02:56:31 +00:00
parent 5078a8a889
commit 23c2b79094
4 changed files with 82 additions and 10 deletions
+2 -1
View File
@@ -17,7 +17,8 @@
"gedmo/doctrine-extensions": "*",
"doctrine/orm": "^2.5",
"monolog/monolog": "^1.12",
"symfony/console": "^3.0"
"symfony/console": "^3.0",
"d11wtq/boris": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "*",
Generated
+41 -3
View File
@@ -4,8 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "ae66861589f917620e6ca83a84e235cd",
"content-hash": "cba343f753537b39dd63a0580b9c2630",
"hash": "403478b1f3decf3db1de90a1d52ac335",
"content-hash": "632b17bac4867a443f9b9420f9ba5955",
"packages": [
{
"name": "behat/transliterator",
@@ -302,6 +302,42 @@
],
"time": "2016-05-04 12:27:30"
},
{
"name": "d11wtq/boris",
"version": "v1.0.10",
"source": {
"type": "git",
"url": "https://github.com/borisrepl/boris.git",
"reference": "31055b15e2d3fe47f31f6aa8e277f8f3fc7eb483"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/borisrepl/boris/zipball/31055b15e2d3fe47f31f6aa8e277f8f3fc7eb483",
"reference": "31055b15e2d3fe47f31f6aa8e277f8f3fc7eb483",
"shasum": ""
},
"require": {
"ext-pcntl": "*",
"ext-posix": "*",
"ext-readline": "*",
"php": ">=5.3.0"
},
"bin": [
"bin/boris"
],
"type": "library",
"autoload": {
"psr-0": {
"Boris": "lib"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "A tiny, but robust REPL (Read-Evaluate-Print-Loop) for PHP.",
"time": "2015-03-01 08:05:19"
},
{
"name": "doctrine/annotations",
"version": "v1.2.7",
@@ -2719,6 +2755,8 @@
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform": {
"php": "^7.0.0"
},
"platform-dev": []
}
+31
View File
@@ -0,0 +1,31 @@
<?php
declare(strict_types = 1);
namespace LotGD\Core\Console\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use LotGD\Core\Console\Main;
class ConsoleCommand extends Command
{
protected function configure()
{
$this->setName('console')
->setDescription('Start a shell to interact with the game.');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$g = Main::createGame();
$boris = new \Boris\Boris('🐲> ');
$boris->setLocal(array(
'g' => $g
));
$boris->start();
}
}
+8 -6
View File
@@ -10,12 +10,13 @@ use LotGD\Core\Game;
use LotGD\Core\Console\Command\{
DatabaseInitCommand,
ModuleValidateCommand,
ModuleRegisterCommand
ModuleRegisterCommand,
ConsoleCommand
};
class Main {
protected static $loader = null;
/**
* Saves a closure used as bootstrap loader
* @param \Closure $loader
@@ -24,7 +25,7 @@ class Main {
{
self::$loader = $loader;
}
/**
* Creates the game using the previously stored bootstrap loader or
* uses the default one
@@ -35,10 +36,10 @@ class Main {
if (is_null(self::$loader)) {
return Bootstrap::createGame();
}
return $loader();
}
public static function main()
{
$application = new Application();
@@ -49,7 +50,8 @@ class Main {
$application->add(new ModuleValidateCommand());
$application->add(new ModuleRegisterCommand());
$application->add(new DatabaseInitCommand());
$application->add(new ConsoleCommand());
$application->run();
}
}