Skip to content

Commit 93c3079

Browse files
committed
fix: added the option to support no-interaction and added a check to run encryption non-interactive only when -n option is present
Signed-off-by: yemkareems <[email protected]>
1 parent 7e546c8 commit 93c3079

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

core/Command/Encryption/EncryptAll.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Symfony\Component\Console\Command\Command;
1414
use Symfony\Component\Console\Helper\QuestionHelper;
1515
use Symfony\Component\Console\Input\InputInterface;
16+
use Symfony\Component\Console\Input\InputOption;
1617
use Symfony\Component\Console\Output\OutputInterface;
1718
use Symfony\Component\Console\Question\ConfirmationQuestion;
1819

@@ -55,6 +56,11 @@ protected function configure() {
5556
$this->setHelp(
5657
'This will encrypt all files for all users. '
5758
. 'Please make sure that no user access his files during this process!'
59+
)->addOption(
60+
'no-interaction',
61+
'n',
62+
InputOption::VALUE_NONE,
63+
'Do not ask any interactive question'
5864
);
5965
}
6066

@@ -77,11 +83,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7783
$output->writeln('Please ensure that no user accesses their files during this time!');
7884
$output->writeln('Note: The encryption module you use determines which files get encrypted.');
7985
$output->writeln('');
86+
$isNoInteraction = $input->getOption('no-interaction');
8087
$question = new ConfirmationQuestion('Do you really want to continue? (y/n) ', false);
8188
if ($input->isInteractive() && $this->questionHelper->ask($input, $output, $question)) {
8289
//run encryption with the answer yes in interactive mode
8390
return $this->runEncryption($input, $output);
84-
} elseif (!$input->isInteractive()) {
91+
} elseif (!$input->isInteractive() && $isNoInteraction) {
8592
//run encryption without the question in non-interactive mode if -n option is available
8693
return $this->runEncryption($input, $output);
8794
}

0 commit comments

Comments
 (0)