Skip to content

Commit

Permalink
🎨 Use exit codes
Browse files Browse the repository at this point in the history
  • Loading branch information
jenssegers committed Oct 3, 2018
1 parent 6e41a8d commit 2fa5e68
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/DownloadCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

$response = $this->client->translations('export', [
'project_id' => (int)$project_id,
'project_id' => (int) $project_id,
'locale' => $input->getArgument('locale'),
'source_file_name' => $input->getArgument('source_file_name'),
]);

if (!$response) {
$output->writeln('<error>Empty OneSky response!</error>');
return;
exit(1);
}

$data = json_decode($response, true);
if (isset($data['meta']) && $data['meta']['status'] != 201) {
$output->writeln('<error>' . $data['meta']['message'] . '</error>');
return;
exit(1);
}

file_put_contents($input->getArgument('file'), $response);
Expand Down
2 changes: 1 addition & 1 deletion src/UploadCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$data = json_decode($response, true);
if (isset($data['meta']) && $data['meta']['status'] != 201) {
$output->writeln('<error>' . $response . '</error>');
return;
exit(1);
}

$output->writeln('<info>File uploaded</info>');
Expand Down

0 comments on commit 2fa5e68

Please sign in to comment.