Skip to content

Commit

Permalink
Leverage to the command exit codes (#673)
Browse files Browse the repository at this point in the history
  • Loading branch information
theofidry authored Jun 20, 2022
1 parent 6f22e83 commit c78fe3c
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/Console/Command/Compile.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ protected function executeCommand(IO $io): int
return $this->generateDockerFile($io);
}

return 0;
return self::SUCCESS;
}

private function createPhar(
Expand Down
12 changes: 6 additions & 6 deletions src/Console/Command/Diff.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ protected function executeCommand(IO $io): int
),
);

return 1;
return self::FAILURE;
}

$result1 = $this->compareArchives($diff, $io);
Expand Down Expand Up @@ -166,7 +166,7 @@ private function compareArchives(PharDiff $diff, IO $io): int
if ($pharInfoA->equals($pharInfoB)) {
$io->success('The two archives are identical');

return 0;
return self::SUCCESS;
}

self::renderArchive(
Expand All @@ -183,7 +183,7 @@ private function compareArchives(PharDiff $diff, IO $io): int
$io,
);

return 1;
return self::FAILURE;
}

private function compareContents(PharDiff $diff, IO $io): int
Expand All @@ -207,14 +207,14 @@ private function compareContents(PharDiff $diff, IO $io): int
if (null === $diffResult || [[], []] === $diffResult) {
$io->success('The contents are identical');

return 0;
return self::SUCCESS;
}

if (is_string($diffResult)) {
// Git or GNU diff: we don't have much control on the format
$io->writeln($diffResult);

return 1;
return self::FAILURE;
}

$io->writeln(sprintf(
Expand Down Expand Up @@ -266,7 +266,7 @@ private function compareContents(PharDiff $diff, IO $io): int
count($diffResult[0]) + count($diffResult[1]),
));

return 1;
return self::FAILURE;
}

private static function renderArchive(string $fileName, PharInfo $pharInfo, IO $io): void
Expand Down
8 changes: 4 additions & 4 deletions src/Console/Command/Extract.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ protected function executeCommand(IO $io): int
$outputDir = $io->getInput()->getArgument(self::OUTPUT_ARG);

if (null === $filePath) {
return 1;
return self::FAILURE;
}

[$box, $cleanUpTmpPhar] = $this->getBox($filePath, $io);

if (null === $box) {
return 1;
return self::FAILURE;
}

$restoreLimit = bump_open_file_descriptor_limit(count($box), $io);
Expand All @@ -84,10 +84,10 @@ protected function executeCommand(IO $io): int
} catch (RuntimeException $exception) {
$io->error($exception->getMessage());

return 1;
return self::FAILURE;
}

return 0;
return self::SUCCESS;
}

private static function getPharFilePath(IO $io): ?string
Expand Down
8 changes: 4 additions & 4 deletions src/Console/Command/GenerateDockerFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ protected function executeCommand(IO $io): int
$pharFilePath = $this->getPharFilePath($io);

if (null === $pharFilePath) {
return 1;
return self::FAILURE;
}

Assert::file($pharFilePath);
Expand Down Expand Up @@ -174,7 +174,7 @@ private function generateFile(string $pharFilePath, string $requirementsPhar, IO
.'requirement checker enabled.',
);

return 1;
return self::FAILURE;
}

$requirements = include $requirementsPhar;
Expand All @@ -196,7 +196,7 @@ private function generateFile(string $pharFilePath, string $requirementsPhar, IO
if (false === $remove) {
$io->writeln('Skipped the docker file generation.');

return 0;
return self::SUCCESS;
}
}

Expand All @@ -214,6 +214,6 @@ private function generateFile(string $pharFilePath, string $requirementsPhar, IO
],
);

return 0;
return self::SUCCESS;
}
}
8 changes: 4 additions & 4 deletions src/Console/Command/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public function executeCommand(IO $io): int
),
);

return 1;
return self::FAILURE;
}

$tmpFile = create_temporary_phar($fileRealPath);
Expand Down Expand Up @@ -179,7 +179,7 @@ public function showInfo(string $file, string $originalFile, IO $io): int
),
);

return 1;
return self::FAILURE;
}
}

Expand Down Expand Up @@ -213,7 +213,7 @@ private static function showGlobalInfo(IO $io): int
$io->newLine();
$io->comment('Get a PHAR details by giving its path as an argument.');

return 0;
return self::SUCCESS;
}

private function showPharInfo(
Expand All @@ -240,7 +240,7 @@ private function showPharInfo(
$io->comment('Use the <info>--list|-l</info> option to list the content of the PHAR.');
}

return 0;
return self::SUCCESS;
}

private function showPharMeta(PharInfo $pharInfo, IO $io): void
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Command/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ protected function executeCommand(IO $io): int
}
}

return 0;
return self::SUCCESS;
}

private static function retrieveCompactors(Configuration $config): Compactors
Expand Down

0 comments on commit c78fe3c

Please sign in to comment.