Skip to content

Commit a3011ff

Browse files
[command] Respect raw output when rendering DevTools banner (#280)
* fix: suppress logo for raw changelog output commands * Update wiki submodule pointer for PR #280 * fix: update changelog to reflect logo suppression for raw output commands Signed-off-by: Felipe Sayão Lobato Abreu <github@mentordosnerds.com> --------- Signed-off-by: Felipe Sayão Lobato Abreu <github@mentordosnerds.com> Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 52d5225 commit a3011ff

4 files changed

Lines changed: 97 additions & 11 deletions

File tree

.github/wiki

Submodule wiki updated from 4782e85 to 7a7e285

CHANGELOG.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10-
### Fixed
11-
12-
- Show the DevTools ASCII logo by default on all top-level command executions, while adding a `--no-logo` global option and automatically suppressing the banner for `--json` / `--pretty-json` invocations (including automatic forwarding of `--no-logo` to internal DevTools subprocesses) to avoid banner repetition in orchestrated command queues (#277)
13-
1410
### Added
1511

1612
- Add a configurable DevTools generated artifact workspace through `--workspace-dir` and `FAST_FORWARD_WORKSPACE_DIR`, keeping explicit output/cache command options authoritative (#274)
1713
- Add a standalone DevTools `self-update` command plus global `--working-dir` and `--auto-update` binary options for local or global installations (#272)
14+
- Show the DevTools ASCII logo by default on all top-level command executions, while adding a `--no-logo` global option and automatically suppressing the banner for `--json` / `--pretty-json` invocations (including automatic forwarding of `--no-logo` to internal DevTools subprocesses) to avoid banner repetition in orchestrated command queues (#277)
15+
16+
### Fixed
17+
18+
- Prevent DevTools from breaking changelog workflows by keeping raw output clean for `changelog:show` and `changelog:next-version` (suppressing the startup ASCII logo when these commands run without explicit `--json`/`--pretty-json`) (#280)
1819

1920
## [1.23.0] - 2026-04-26
2021

src/Console/DevTools.php

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,16 @@ final class DevTools extends Application
5757

5858
LOGO;
5959

60+
/**
61+
* Commands that require raw output and therefore must not render the logo.
62+
*
63+
* @var list<string>
64+
*/
65+
private const array RAW_OUTPUT_COMMANDS = [
66+
'changelog:next-version',
67+
'changelog:show',
68+
];
69+
6070
/**
6171
* @var ContainerInterface holds the static container instance for global access within the DevTools context
6272
*/
@@ -139,11 +149,7 @@ protected function getDefaultInputDefinition(): InputDefinition
139149
#[Override]
140150
public function doRun(InputInterface $input, OutputInterface $output): int
141151
{
142-
$noLogo = (bool) $input->getParameterOption('--no-logo', null, true)
143-
|| (bool) $input->hasParameterOption('--json', true)
144-
|| (bool) $input->hasParameterOption('--pretty-json', true);
145-
146-
if (! $noLogo) {
152+
if ($this->shouldRenderLogo($input)) {
147153
$output->writeln(self::LOGO);
148154
}
149155

@@ -156,7 +162,7 @@ public function doRun(InputInterface $input, OutputInterface $output): int
156162
return Command::FAILURE;
157163
}
158164

159-
if (! $noLogo && ! $this->isSelfUpdateCommand($input)) {
165+
if ($this->shouldRenderLogo($input) && ! $this->isSelfUpdateCommand($input)) {
160166
$this->runAutoUpdateWhenRequested($input, $output);
161167
$this->versionCheckNotifier->notify($output);
162168
}
@@ -243,6 +249,40 @@ private function runAutoUpdateWhenRequested(InputInterface $input, OutputInterfa
243249
}
244250
}
245251

252+
/**
253+
* Determines whether the startup logo should be rendered for this invocation.
254+
*
255+
* @param InputInterface $input the application input
256+
*/
257+
private function shouldRenderLogo(InputInterface $input): bool
258+
{
259+
if ((bool) $input->getParameterOption('--no-logo', null, true)) {
260+
return false;
261+
}
262+
263+
if ((bool) $input->hasParameterOption('--json', true) || (bool) $input->hasParameterOption('--pretty-json', true)) {
264+
return false;
265+
}
266+
267+
return ! $this->isRawOutputCommand($input);
268+
}
269+
270+
/**
271+
* Checks whether the current command is designed for raw output mode.
272+
*
273+
* @param InputInterface $input the application input
274+
*/
275+
private function isRawOutputCommand(InputInterface $input): bool
276+
{
277+
$commandName = $input->getFirstArgument();
278+
279+
if (! is_string($commandName)) {
280+
return false;
281+
}
282+
283+
return \in_array($commandName, self::RAW_OUTPUT_COMMANDS, true);
284+
}
285+
246286
/**
247287
* Detects whether the current invocation targets the self-update command.
248288
*

tests/Console/DevToolsTest.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
use Override;
5050
use PHPUnit\Framework\Attributes\CoversClass;
5151
use PHPUnit\Framework\Attributes\Test;
52+
use PHPUnit\Framework\Attributes\TestWith;
5253
use PHPUnit\Framework\Attributes\UsesClass;
5354
use PHPUnit\Framework\TestCase;
5455
use Prophecy\PhpUnit\ProphecyTrait;
@@ -362,6 +363,50 @@ protected function configure(): void
362363
self::assertStringNotContainsString('_____', $output->fetch());
363364
}
364365

366+
/**
367+
* @return void
368+
*/
369+
#[Test]
370+
#[TestWith(['changelog:show'])]
371+
#[TestWith(['changelog:next-version'])]
372+
public function doRunWillNotRenderLogoWhenRawOutputCommandIsRequested(string $commandName): void
373+
{
374+
$command = new class extends Command {
375+
public function __construct()
376+
{
377+
parent::__construct('placeholder');
378+
$this->setCode(static fn(InputInterface $input, OutputInterface $output): int => Command::SUCCESS);
379+
}
380+
};
381+
382+
$command->setName($commandName);
383+
384+
$this->commandLoader->has($commandName)
385+
->willReturn(true)
386+
->shouldBeCalledOnce();
387+
$this->commandLoader->get($commandName)
388+
->willReturn($command)
389+
->shouldBeCalledOnce();
390+
391+
$input = new ArrayInput([
392+
'command' => $commandName,
393+
]);
394+
395+
$output = new BufferedOutput();
396+
397+
$this->environment->get('FAST_FORWARD_AUTO_UPDATE', '')
398+
->willReturn('');
399+
$this->workingDirectorySwitcher->switchTo(null)
400+
->shouldBeCalledOnce();
401+
$this->versionCheckNotifier->notify($output)
402+
->shouldNotBeCalled();
403+
404+
$result = $this->invokeDoRun($input, $output);
405+
406+
self::assertSame(Command::SUCCESS, $result);
407+
self::assertStringNotContainsString('_____', $output->fetch());
408+
}
409+
365410
/**
366411
* @return void
367412
*/

0 commit comments

Comments
 (0)