Skip to content

Commit

Permalink
Merge pull request #21 from yiisoft/pass-arguments
Browse files Browse the repository at this point in the history
Pass console argument at startup
  • Loading branch information
xepozz authored Jul 29, 2022
2 parents 9857aa5 + d887231 commit 3582eb0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## 1.0.2 under development

- no changes in this release.
- Chg: #21: Add passing input aggregate to the console application (@xepozz)

## 1.0.1 June 17, 2022

Expand Down
10 changes: 7 additions & 3 deletions src/ConsoleApplicationRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Exception;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Symfony\Component\Console\Input\ArgvInput;
use Throwable;
use Yiisoft\Definitions\Exception\CircularReferenceException;
use Yiisoft\Definitions\Exception\InvalidConfigException;
Expand Down Expand Up @@ -53,11 +54,14 @@ public function run(): void
$application = $container->get(Application::class);
$exitCode = ExitCode::UNSPECIFIED_ERROR;

$input = new ArgvInput();
$output = new ConsoleBufferedOutput();

try {
$application->start();
$exitCode = $application->run(null, new ConsoleBufferedOutput());
$application->start($input);
$exitCode = $application->run($input, $output);
} catch (Throwable $throwable) {
$application->renderThrowable($throwable, new ConsoleBufferedOutput());
$application->renderThrowable($throwable, $output);
} finally {
$application->shutdown($exitCode);
exit($exitCode);
Expand Down

0 comments on commit 3582eb0

Please sign in to comment.