Skip to content

Commit 8a13d1b

Browse files
committed
added interact action
1 parent 420ad7f commit 8a13d1b

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

bin/leaf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ $app = new Symfony\Component\Console\Application('Leaf CLI', '1.0.0');
1010

1111
$app->add(new Leaf\Console\CreateCommand);
1212
$app->add(new Leaf\Console\App\ServeCommand);
13+
$app->add(new Leaf\Console\App\InteractCommand);
1314

1415
$app->run();

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"php": "^7.2",
1717
"ext-zip": "*",
1818
"guzzlehttp/guzzle": "^6.0",
19+
"psy/psysh": "^0.10.0@dev",
1920
"symfony/console": "^4.0|^5.0",
2021
"symfony/filesystem": "^4.0|^5.0",
2122
"symfony/process": "^4.0|^5.0"

src/App/InteractCommand.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace Leaf\Console\App;
4+
5+
use Symfony\Component\Console\Command\Command;
6+
use Symfony\Component\Console\Input\InputInterface;
7+
use Symfony\Component\Console\Output\OutputInterface;
8+
use Psy\Shell;
9+
10+
class InteractCommand extends Command {
11+
protected static $defaultName = "app:interact";
12+
13+
protected function configure() {
14+
$this
15+
->setDescription("Interact with your application")
16+
->setHelp("Interact with your application");
17+
}
18+
19+
20+
protected function execute(InputInterface $input, OutputInterface $output) {
21+
if (file_exists("vendor/autoload.php")) require "vendor/autoload.php";
22+
if (file_exists("Config/bootstrap.php")) require "Config/bootstrap.php";
23+
if (file_exists("index.php") && !file_exists("leaf")) require "index.php";
24+
25+
$output->writeln("<info>Leaf interactive shell activated</info>");
26+
$shell = new Shell();
27+
$output->write($shell->run());
28+
}
29+
}

0 commit comments

Comments
 (0)