Skip to content

Fixed confirmation questions #186

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

Merged
merged 1 commit into from
Sep 28, 2016
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
17 changes: 4 additions & 13 deletions src/PHPCR/Shell/Config/ConfigManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public function getPhpcrshConfig()
/**
* Initialize a configuration files.
*/
public function initConfig(OutputInterface $output = null, $noInteraction = false)
public function initConfig(OutputInterface $output = null)
{
$log = function ($message) use ($output) {
if ($output) {
Expand Down Expand Up @@ -208,18 +208,9 @@ public function initConfig(OutputInterface $output = null, $noInteraction = fals
}

if ($this->filesystem->exists($destFile)) {
if (false === $noInteraction) {
$confirmed = $this->questionHelper->askConfirmation(
$output,
'"'.$configFilename.'" already exists, do you want to overwrite it?'
);

if (!$confirmed) {
continue;
}
} else {
$log(sprintf('<info>File</info> %s <info> already exists, not overwriting.', $destFile));
}
$log(sprintf('<info>File</info> %s <info> already exists, not overwriting.', $destFile));

return;
}

$this->filesystem->copy($srcFile, $destFile);
Expand Down
3 changes: 2 additions & 1 deletion src/PHPCR/Shell/Console/Command/Phpcr/NodeEditCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\ConfirmationQuestion;
use Symfony\Component\Serializer\Serializer;

class NodeEditCommand extends BasePhpcrCommand
Expand Down Expand Up @@ -121,7 +122,7 @@ public function execute(InputInterface $input, OutputInterface $output)
$error = $e->getMessage();
$output->writeln('<error>'.$error.'</error>');
if (false === $input->getOption('no-interaction')) {
$tryAgain = $dialog->askConfirmation($output, 'Do you want to try again? (y/n)');
$tryAgain = $dialog->ask($input, $output, new ConfirmationQuestion('Do you want to try again? (y/n)'));
}
$outStr = $inStr;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function execute(InputInterface $input, OutputInterface $output)
if ($type) {
$intType = PropertyType::valueFromName($type);

if ($intType === PropertyType::REFERENCE || $intType === PropertyType::WEAKREFERENCE) {
if ($intType === PropertyType::REFERENCE || $intType === PropertyType::WEAKREFERENCE) {
// convert path to UUID
if (false === UUIDHelper::isUuid($value)) {
$path = $value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\ConfirmationQuestion;

class NodeTypeEditCommand extends BasePhpcrCommand
{
Expand Down Expand Up @@ -101,7 +102,7 @@ public function execute(InputInterface $input, OutputInterface $output)

$tryAgain = false;
if (false === $input->getOption('no-interaction')) {
$tryAgain = $dialog->askConfirmation($output, 'Do you want to try again? (y/n)');
$tryAgain = $dialog->ask($input, $output, new ConfirmationQuestion('Do you want to try again? (y/n)'));
}

if (false === $tryAgain) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\ConfirmationQuestion;

class SessionExportCommand extends BasePhpcrCommand
{
Expand Down Expand Up @@ -64,7 +65,7 @@ public function execute(InputInterface $input, OutputInterface $output)
$confirmed = true;

if (false === $input->getOption('no-interaction')) {
$confirmed = $dialog->askConfirmation($output, 'File already exists, overwrite?');
$confirmed = $dialog->ask($input, $output, new ConfirmationQuestion('File already exists, overwrite?'));
}

if (false === $confirmed) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ public function execute(InputInterface $input, OutputInterface $output)
{
$this->output = $output;
$configHelper = $this->get('config.manager');
$configHelper->initConfig($output, $input->getOption('no-interaction'));
$configHelper->initConfig($output);
}
}
4 changes: 2 additions & 2 deletions src/PHPCR/Shell/Console/Command/Shell/ExitCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use PHPCR\Shell\Console\Command\BaseCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\ConfirmationQuestion;

class ExitCommand extends BaseCommand
{
Expand All @@ -28,13 +29,12 @@ public function execute(InputInterface $input, OutputInterface $output)
{
$dialog = $this->get('helper.question');
$session = $this->get('phpcr.session');
$noInteraction = $input->getOption('no-interaction');

if ($session->hasPendingChanges()) {
$res = false;

if ($input->isInteractive()) {
$res = $dialog->askConfirmation($output, '<question>Session has pending changes, are you sure you want to quit? (Y/N)</question>', false);
$res = $dialog->ask($input, $output, new ConfirmationQuestion('<question>Session has pending changes, are you sure you want to quit? (Y/N)</question>', false));
}

if (false === $res) {
Expand Down
5 changes: 3 additions & 2 deletions src/PHPCR/Shell/Subscriber/ProfileWriterSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use PHPCR\Shell\Event\PhpcrShellEvents;
use PHPCR\Shell\Event\ProfileInitEvent;
use Symfony\Component\Console\Helper\QuestionHelper;
use Symfony\Component\Console\Question\ConfirmationQuestion;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class ProfileWriterSubscriber implements EventSubscriberInterface
Expand Down Expand Up @@ -54,14 +55,14 @@ public function handleProfileInit(ProfileInitEvent $e)
if (file_exists($this->profileLoader->getProfilePath($profileName))) {
$res = true;
if (false === $noInteraction) {
$res = $this->questionHelper->askConfirmation($output, sprintf('Update existing profile "%s"?', $profileName));
$res = $this->questionHelper->ask($input, $output, new ConfirmationQuestion(sprintf('Update existing profile "%s"?', $profileName)));
}
$overwrite = true;
} else {
$res = true;

if (false === $noInteraction) {
$res = $this->questionHelper->askConfirmation($output, sprintf('Create new profile "%s"?', $profileName));
$res = $this->questionHelper->ask($input, $output, new ConfirmationQuestion(sprintf('Create new profile "%s"?', $profileName)));
}
}

Expand Down