-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option on setup to execute commands
- Loading branch information
Pedro Sanchez
committed
Nov 30, 2017
1 parent
a184448
commit 34d553e
Showing
3 changed files
with
86 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace DalaiLomo\ACE\Setup\Section; | ||
|
||
use DalaiLomo\ACE\Helper\CommandOutputHelper; | ||
use DalaiLomo\ACE\Setup\Menu\InteractiveMenu; | ||
use DalaiLomo\ACE\Setup\Section\ExecutorSection\ExecutorGroupSection; | ||
use Symfony\Component\Console\Question\Question; | ||
|
||
class ExecutorSection extends AbstractSection | ||
{ | ||
public function getSectionName() | ||
{ | ||
return 'Execute group'; | ||
} | ||
|
||
public function doAction() | ||
{ | ||
$interactiveMenu = new InteractiveMenu($this->input, $this->output, $this->question, $this->config); | ||
$interactiveMenu->setOptionQuitText('Back to main menu'); | ||
|
||
$this->config->onEachKey(function($groups, $key) use ($interactiveMenu) { | ||
$interactiveMenu->registerSection(new ExecutorGroupSection($groups, $key)); | ||
}); | ||
|
||
$interactiveMenu->run(); | ||
|
||
$this->output->writeln(CommandOutputHelper::clearOutput()); | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
src/Setup/Section/ExecutorSection/ExecutorGroupSection.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
namespace DalaiLomo\ACE\Setup\Section\ExecutorSection; | ||
|
||
use DalaiLomo\ACE\Command\ExecuteCommand; | ||
use DalaiLomo\ACE\Helper\CommandOutputHelper; | ||
use DalaiLomo\ACE\Setup\Section\AbstractSection; | ||
use Symfony\Component\Console\Application; | ||
use Symfony\Component\Console\Input\ArrayInput; | ||
use Symfony\Component\Console\Output\BufferedOutput; | ||
use Symfony\Component\Console\Output\ConsoleOutput; | ||
use Symfony\Component\Console\Output\StreamOutput; | ||
|
||
class ExecutorGroupSection extends AbstractSection | ||
{ | ||
/** | ||
* @var array | ||
*/ | ||
private $groups; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $key; | ||
|
||
public function __construct(array $groups, string $key) | ||
{ | ||
$this->groups = $groups; | ||
$this->key = $key; | ||
} | ||
|
||
public function getSectionName() | ||
{ | ||
return sprintf('Execute group with key "%s"', $this->key); | ||
} | ||
|
||
public function doAction() | ||
{ | ||
$input = new ArrayInput([ | ||
'--key' => $this->key, | ||
]); | ||
|
||
$output = new ConsoleOutput(); | ||
$output->setDecorated(true); | ||
|
||
$executeCommand = new ExecuteCommand(); | ||
$executeCommand->run($input, $output); | ||
|
||
readline('Finished. Press "Enter" to continue'); | ||
|
||
$this->output->writeln(CommandOutputHelper::clearOutput()); | ||
} | ||
} |