Skip to content

Commit

Permalink
places-setup: refactor error display
Browse files Browse the repository at this point in the history
Signed-off-by: Varun Patil <[email protected]>
  • Loading branch information
pulsejet committed Sep 20, 2024
1 parent ac512fb commit 05d68e8
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions lib/Command/PlacesSetup.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,21 +108,15 @@ protected function warnDownloaded(): bool
$this->output->writeln('Are you sure you want to download the planet database?');
$this->output->write('Proceed? [y/N] ');

// Redirect -n users to --force
if (!$this->input->isInteractive()) {
$this->output->writeln(
"\n<error>Non-interactive mode with -n is not supported. ".
'You can use --force instead.</error>',
);

return false;
}

// Read user input
$handle = fopen('php://stdin', 'r');
$line = fgets($handle);
$line = $this->input->isInteractive() ? fgets($handle) : false;
if (false === $line) {
$this->output->writeln('<error>You need an interactive terminal to run this command</error>');
// Redirect any -n users to --force
$this->output->writeln(
"\n<error>You need an interactive terminal to run this command, ".
'or use --force for non-interactive mode.</error>',
);

return false;
}
Expand Down

0 comments on commit 05d68e8

Please sign in to comment.