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

Leverage to the command exit codes #673

Merged
merged 1 commit into from
Jun 20, 2022
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
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