From 25fb2f727851a56c99b99abf92451e835b7ae11c Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 11 Jun 2021 14:33:25 +0200 Subject: [PATCH] [Runtime] fix overriding --env|-e with single-command apps --- src/Symfony/Component/Runtime/SymfonyRuntime.php | 1 + src/Symfony/Component/Runtime/Tests/phpt/command.php | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Runtime/SymfonyRuntime.php b/src/Symfony/Component/Runtime/SymfonyRuntime.php index 461f38e7767ee..9df2f5ca4b7b3 100644 --- a/src/Symfony/Component/Runtime/SymfonyRuntime.php +++ b/src/Symfony/Component/Runtime/SymfonyRuntime.php @@ -131,6 +131,7 @@ public function getRunner(?object $application): RunnerInterface } $console->setDefaultCommand($application->getName(), true); + $console->getDefinition()->addOptions($application->getDefinition()->getOptions()); return $this->getRunner($console); } diff --git a/src/Symfony/Component/Runtime/Tests/phpt/command.php b/src/Symfony/Component/Runtime/Tests/phpt/command.php index 42d66c1c98462..f8ba65133e7db 100644 --- a/src/Symfony/Component/Runtime/Tests/phpt/command.php +++ b/src/Symfony/Component/Runtime/Tests/phpt/command.php @@ -2,14 +2,15 @@ use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; require __DIR__.'/autoload.php'; return function (Command $command, InputInterface $input, OutputInterface $output, array $context) { - $command->setCode(function () use ($output, $context) { - $output->write('OK Command '.$context['SOME_VAR']); - }); + $command->addOption('hello', 'e', InputOption::VALUE_REQUIRED, 'How should I greet?', 'OK'); - return $command; + return $command->setCode(function () use ($input, $output, $context) { + $output->write($input->getOption('hello').' Command '.$context['SOME_VAR']); + }); }; pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy