From 33fa45ffc81fdcc1ca368d4946da859c8cdb58d9 Mon Sep 17 00:00:00 2001 From: MatTheCat Date: Wed, 2 Nov 2022 18:15:44 +0100 Subject: [PATCH 1/7] Tell about messenger:consume invalid limit options --- Exception/InvalidOptionException.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exception/InvalidOptionException.php b/Exception/InvalidOptionException.php index b2eec6165..5cf62792e 100644 --- a/Exception/InvalidOptionException.php +++ b/Exception/InvalidOptionException.php @@ -12,7 +12,7 @@ namespace Symfony\Component\Console\Exception; /** - * Represents an incorrect option name typed in the console. + * Represents an incorrect option name or value typed in the console. * * @author Jérôme Tamarelle */ From afcca7c3e51dab9003ed837b2384c2bc7b7ff2e0 Mon Sep 17 00:00:00 2001 From: maxbeckers Date: Wed, 26 Oct 2022 09:13:33 +0200 Subject: [PATCH 2/7] [Console] Fix console `ProgressBar::override()` after manual `ProgressBar::cleanup()` --- Helper/ProgressBar.php | 11 +++++++---- Tests/Helper/ProgressBarTest.php | 31 +++++++++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/Helper/ProgressBar.php b/Helper/ProgressBar.php index b1fb213b6..ddc5870aa 100644 --- a/Helper/ProgressBar.php +++ b/Helper/ProgressBar.php @@ -474,10 +474,13 @@ private function overwrite(string $message): void } $this->output->clear($lineCount); } else { - for ($i = 0; $i < $this->formatLineCount; ++$i) { - $this->cursor->moveToColumn(1); - $this->cursor->clearLine(); - $this->cursor->moveUp(); + if ('' !== $this->previousMessage) { + // only clear upper lines when last call was not a clear + for ($i = 0; $i < $this->formatLineCount; ++$i) { + $this->cursor->moveToColumn(1); + $this->cursor->clearLine(); + $this->cursor->moveUp(); + } } $this->cursor->moveToColumn(1); diff --git a/Tests/Helper/ProgressBarTest.php b/Tests/Helper/ProgressBarTest.php index ef5f06222..17401b887 100644 --- a/Tests/Helper/ProgressBarTest.php +++ b/Tests/Helper/ProgressBarTest.php @@ -812,8 +812,10 @@ public function testMultilineFormat() $this->assertEquals( ">---------------------------\nfoobar". $this->generateOutput("=========>------------------\nfoobar"). - "\x1B[1G\x1B[2K\x1B[1A\x1B[1G\x1B[2K". - $this->generateOutput("============================\nfoobar"), + "\x1B[1G\x1B[2K\x1B[1A". + $this->generateOutput(''). + $this->generateOutput('============================'). + "\nfoobar", stream_get_contents($output->getStream()) ); } @@ -1124,4 +1126,29 @@ public function testMultiLineFormatIsFullyCleared() stream_get_contents($output->getStream()) ); } + + public function testMultiLineFormatIsFullyCorrectlyWithManuallyCleanup() + { + ProgressBar::setFormatDefinition('normal_nomax', "[%bar%]\n%message%"); + $bar = new ProgressBar($output = $this->getOutputStream()); + $bar->setMessage('Processing "foobar"...'); + $bar->start(); + $bar->clear(); + $output->writeln('Foo!'); + $bar->display(); + $bar->finish(); + + rewind($output->getStream()); + $this->assertEquals( + "[>---------------------------]\n". + 'Processing "foobar"...'. + "\x1B[1G\x1B[2K\x1B[1A". + $this->generateOutput(''). + 'Foo!'.\PHP_EOL. + $this->generateOutput('[--->------------------------]'). + "\nProcessing \"foobar\"...". + $this->generateOutput("[----->----------------------]\nProcessing \"foobar\"..."), + stream_get_contents($output->getStream()) + ); + } } From 01c90dba590bcdc5699597b8090407b4441dfad4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Mon, 14 Nov 2022 00:00:47 +0100 Subject: [PATCH 3/7] Fix signal handlers called after event listeners and skip exit --- Application.php | 8 ++++---- Tests/ApplicationTest.php | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Application.php b/Application.php index 53be6d055..29951e9c1 100644 --- a/Application.php +++ b/Application.php @@ -1012,10 +1012,6 @@ protected function doRunCommand(Command $command, InputInterface $input, OutputI }); } } - - foreach ($commandSignals as $signal) { - $this->signalRegistry->register($signal, [$command, 'handleSignal']); - } } if (null !== $this->dispatcher) { @@ -1034,6 +1030,10 @@ protected function doRunCommand(Command $command, InputInterface $input, OutputI }); } } + + foreach ($commandSignals as $signal) { + $this->signalRegistry->register($signal, [$command, 'handleSignal']); + } } if (null === $this->dispatcher) { diff --git a/Tests/ApplicationTest.php b/Tests/ApplicationTest.php index 641415d28..fdb9b3f33 100644 --- a/Tests/ApplicationTest.php +++ b/Tests/ApplicationTest.php @@ -1975,6 +1975,21 @@ public function testSignalableCommandInterfaceWithoutSignals() $this->assertSame(0, $application->run(new ArrayInput(['signal']))); } + public function testSignalableCommandHandlerCalledAfterEventListener() + { + $command = new SignableCommand(); + + $subscriber = new SignalEventSubscriber(); + + $dispatcher = new EventDispatcher(); + $dispatcher->addSubscriber($subscriber); + + $application = $this->createSignalableApplication($command, $dispatcher); + $application->setSignalsToDispatchEvent(\SIGUSR1); + $this->assertSame(1, $application->run(new ArrayInput(['signal']))); + $this->assertSame([SignalEventSubscriber::class, SignableCommand::class], $command->signalHandlers); + } + /** * @group tty */ @@ -2076,6 +2091,7 @@ public function isEnabled(): bool class BaseSignableCommand extends Command { public $signaled = false; + public $signalHandlers = []; public $loop = 1000; private $emitsSignal; @@ -2116,6 +2132,7 @@ public function getSubscribedSignals(): array public function handleSignal(int $signal): void { $this->signaled = true; + $this->signalHandlers[] = __CLASS__; } } @@ -2127,6 +2144,7 @@ public function onSignal(ConsoleSignalEvent $event): void { $this->signaled = true; $event->getCommand()->signaled = true; + $event->getCommand()->signalHandlers[] = __CLASS__; } public static function getSubscribedEvents(): array From dcda52724f818e0113e7ae74d5b7c42bb6cb7f81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Tue, 15 Nov 2022 21:39:33 +0100 Subject: [PATCH 4/7] Improve message when shell is not detected --- Command/DumpCompletionCommand.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Command/DumpCompletionCommand.php b/Command/DumpCompletionCommand.php index dc0cfaef7..518d606a0 100644 --- a/Command/DumpCompletionCommand.php +++ b/Command/DumpCompletionCommand.php @@ -93,8 +93,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int if (!file_exists($completionFile)) { $supportedShells = $this->getSupportedShells(); - ($output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output) - ->writeln(sprintf('Detected shell "%s", which is not supported by Symfony shell completion (supported shells: "%s").', $shell, implode('", "', $supportedShells))); + if ($output instanceof ConsoleOutputInterface) { + $output = $output->getErrorOutput(); + } + if ($shell) { + $output->writeln(sprintf('Detected shell "%s", which is not supported by Symfony shell completion (supported shells: "%s").', $shell, implode('", "', $supportedShells))); + } else { + $output->writeln(sprintf('Shell not detected, Symfony shell completion only supports "%s").', implode('", "', $supportedShells))); + } return self::INVALID; } From f2dd071d091edca54ac2ad4acb549be7463af975 Mon Sep 17 00:00:00 2001 From: Chi-teck Date: Wed, 9 Nov 2022 22:12:42 +0500 Subject: [PATCH 5/7] Support completion for bash functions --- Resources/completion.bash | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Resources/completion.bash b/Resources/completion.bash index bf3edf511..64b87ccf7 100644 --- a/Resources/completion.bash +++ b/Resources/completion.bash @@ -11,13 +11,14 @@ _sf_{{ COMMAND_NAME }}() { local sf_cmd="${COMP_WORDS[0]}" # for an alias, get the real script behind it - if [[ $(type -t $sf_cmd) == "alias" ]]; then + sf_cmd_type=$(type -t $sf_cmd) + if [[ $sf_cmd_type == "alias" ]]; then sf_cmd=$(alias $sf_cmd | sed -E "s/alias $sf_cmd='(.*)'/\1/") - else + elif [[ $sf_cmd_type == "file" ]]; then sf_cmd=$(type -p $sf_cmd) fi - if [ ! -x "$sf_cmd" ]; then + if [[ $sf_cmd_type != "function" && ! -x $sf_cmd ]]; then return 1 fi From 3042c617e88dd2cf77cd3700c4fe996d1f2edabf Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 25 Nov 2022 12:02:30 +0100 Subject: [PATCH 6/7] skip a test if the signal to be sent is not available --- Tests/ApplicationTest.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Tests/ApplicationTest.php b/Tests/ApplicationTest.php index fdb9b3f33..aa4901be6 100644 --- a/Tests/ApplicationTest.php +++ b/Tests/ApplicationTest.php @@ -1945,6 +1945,10 @@ public function testSignalSubscriber() */ public function testSetSignalsToDispatchEvent() { + if (!\defined('SIGUSR1')) { + $this->markTestSkipped('SIGUSR1 not available'); + } + $command = new BaseSignableCommand(); $subscriber = new SignalEventSubscriber(); From 8e9b9c8dfb33af6057c94e1b44846bee700dc5ef Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 25 Nov 2022 15:09:27 +0100 Subject: [PATCH 7/7] skip tests if the signal to be sent is not available --- Tests/ApplicationTest.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Tests/ApplicationTest.php b/Tests/ApplicationTest.php index aa4901be6..9f85975ad 100644 --- a/Tests/ApplicationTest.php +++ b/Tests/ApplicationTest.php @@ -1981,6 +1981,10 @@ public function testSignalableCommandInterfaceWithoutSignals() public function testSignalableCommandHandlerCalledAfterEventListener() { + if (!\defined('SIGUSR1')) { + $this->markTestSkipped('SIGUSR1 not available'); + } + $command = new SignableCommand(); $subscriber = new SignalEventSubscriber(); 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