This commit is contained in:
2023-11-30 17:02:21 +08:00
parent c29362be7c
commit 66ef753b67
4 changed files with 20 additions and 56 deletions
+11 -7
View File
@@ -120,15 +120,17 @@ class Application extends BaseApplication
/**
* @param string $command
* @param string ...$command
* @return void
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function command(string $command): void
public function command(string ...$command): void
{
$console = $this->container->get(ConsoleApplication::class);
$console->add($this->container->get($command));
foreach ($command as $value) {
$console->add($this->container->get($value));
}
}
@@ -142,17 +144,19 @@ class Application extends BaseApplication
*/
public function execute(array $argv): void
{
[$input, $output] = [new ArgvInput($argv), new ConsoleOutput()];
$this->container->bind(ArgvInput::class, $input);
$this->container->bind(OutputInterface::class, $output);
/** @var ArgvInput $input */
$input = $this->container->bind(ArgvInput::class, new ArgvInput($argv));
/** @var ConsoleOutput $output */
$output = $this->container->bind(OutputInterface::class, new ConsoleOutput());
$console = $this->container->get(ConsoleApplication::class);
$command = $console->find($input->getFirstArgument() ?? 'list');
fire(new OnBeforeCommandExecute($command));
$command->run($input, $output);
fire(new OnAfterCommandExecute($command));
$output->writeln('execute complete.');
}