-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Console.php
65 lines (55 loc) · 1.38 KB
/
Console.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php declare(strict_types = 1);
/**
* ConsoleApplication.php
*
* @license More in LICENSE.md
* @copyright https://www.fastybird.com
* @author Adam Kadlec <adam.kadlec@fastybird.com>
* @package FastyBird:WebServer!
* @subpackage Application
* @since 0.1.0
*
* @date 21.05.21
*/
namespace FastyBird\WebServer\Application;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input;
use Symfony\Component\Console\Output;
use Throwable;
/**
* Console application
*
* @package FastyBird:WebServer!
* @subpackage Application
*
* @author Adam Kadlec <adam.kadlec@fastybird.com>
*/
class Console implements IConsole
{
/** @var Application */
private Application $application;
public function __construct(
?Application $application = null
) {
$this->application = $application ?? new Application();
}
/**
* @param Input\InputInterface|null $input
* @param Output\OutputInterface|null $output
*
* @return int
*
* @throws Throwable
*/
public function run(?Input\InputInterface $input = null, ?Output\OutputInterface $output = null): int
{
if ($input === null) {
$input = new Input\ArrayInput([
'command' => 'fb:web-server:start',
]);
} else {
$input->setArgument('command', 'fb:web-server:start');
}
return $this->application->run($input, $output);
}
}