Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debug:unassigned now returns exit status 2 when the command ran successfully, but there were some unassigned tokens. #1398

Merged
merged 3 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ examples\Layer1\SomeClass
examples\Layer1\SomeClass2
```

This command exist with the return code 2 when it ran successfully, but there
were some tokens in the output. You can use this information in your CI
pipelines.

## `debug:dependencies`

With the `debug:dependencies`-command you can see all dependencies of your layer. You can optionally specify a target layer to get only dependencies from one layer to the other:
Expand Down
7 changes: 4 additions & 3 deletions src/Supportive/Console/Command/DebugUnassignedCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class DebugUnassignedCommand extends Command
{
public static $defaultName = 'debug:unassigned';
public static $defaultDescription = 'Lists tokens that are not assigned to any layer';
public const EXIT_WITH_UNASSIGNED_TOKENS = 2;

public function __construct(private readonly DebugUnassignedRunner $runner)
{
Expand All @@ -27,13 +28,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$symfonyOutput = new SymfonyOutput($output, $outputStyle);

try {
$this->runner->run($symfonyOutput);
$result = $this->runner->run($symfonyOutput);

return $result ? self::EXIT_WITH_UNASSIGNED_TOKENS : self::SUCCESS;
} catch (CommandRunException $exception) {
$outputStyle->error($exception->getMessage());

return self::FAILURE;
}

return self::SUCCESS;
}
}
8 changes: 6 additions & 2 deletions src/Supportive/Console/Command/DebugUnassignedRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ final class DebugUnassignedRunner
public function __construct(private readonly UnassignedTokenAnalyser $analyser) {}

/**
* @return bool are there any unassigned tokens?
*
* @throws CommandRunException
*/
public function run(OutputInterface $output): void
public function run(OutputInterface $output): bool
{
try {
$unassignedTokens = $this->analyser->findUnassignedTokens();
Expand All @@ -29,9 +31,11 @@ public function run(OutputInterface $output): void
if ([] === $unassignedTokens) {
$output->writeLineFormatted('There are no unassigned tokens.');

return;
return false;
}

$output->writeLineFormatted($unassignedTokens);

return true;
}
}
Loading