Skip to content

Commit 26e2ff9

Browse files
committed
fix: removed the -n option from options, added the check and made default answer to both questions true to support -n run directly
Signed-off-by: yemkareems <[email protected]>
1 parent d420b3f commit 26e2ff9

File tree

2 files changed

+13
-17
lines changed

2 files changed

+13
-17
lines changed

apps/encryption/lib/Crypto/EncryptAll.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -278,12 +278,8 @@ protected function outputPasswords(): void {
278278
$this->writePasswordsToFile($newPasswords);
279279

280280
$this->output->writeln('');
281-
if ($this->input->isInteractive()) {
282-
$question = new ConfirmationQuestion('Do you want to send the passwords directly to the users by mail? (y/n) ', false);
283-
if ($this->questionHelper->ask($this->input, $this->output, $question)) {
284-
$this->sendPasswordsByMail();
285-
}
286-
} elseif (!$this->input->isInteractive() && $this->input->getOption('no-interaction')) {
281+
$question = new ConfirmationQuestion('Do you want to send the passwords directly to the users by mail? (y/n) ', true);
282+
if ($this->questionHelper->ask($this->input, $this->output, $question)) {
287283
$this->sendPasswordsByMail();
288284
}
289285
}

core/Command/Encryption/EncryptAll.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,22 @@ protected function configure() {
5656
$this->setHelp(
5757
'This will encrypt all files for all users. '
5858
. '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'
6459
);
6560
}
6661

6762
/**
6863
* @throws \Exception
6964
*/
7065
protected function execute(InputInterface $input, OutputInterface $output): int {
66+
if (!$input->isInteractive() && !$input->getOption('no-interaction')) {
67+
$output->writeln('Invalid TTY.');
68+
$output->writeln('If you are trying to execute the command in a Docker ');
69+
$output->writeln("container, do not forget to execute 'docker exec' with");
70+
$output->writeln("the '-i' and '-t' options.");
71+
$output->writeln('');
72+
return 1;
73+
}
74+
7175
if ($this->encryptionManager->isEnabled() === false) {
7276
throw new \Exception('Server side encryption is not enabled');
7377
}
@@ -83,14 +87,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8387
$output->writeln('Please ensure that no user accesses their files during this time!');
8488
$output->writeln('Note: The encryption module you use determines which files get encrypted.');
8589
$output->writeln('');
86-
$isNoInteraction = $input->getOption('no-interaction');
87-
$question = new ConfirmationQuestion('Do you really want to continue? (y/n) ', false);
88-
if ($input->isInteractive() && $this->questionHelper->ask($input, $output, $question)) {
90+
$question = new ConfirmationQuestion('Do you really want to continue? (y/n) ', true);
91+
if ($this->questionHelper->ask($input, $output, $question)) {
8992
//run encryption with the answer yes in interactive mode
9093
return $this->runEncryption($input, $output);
91-
} elseif (!$input->isInteractive() && $isNoInteraction) {
92-
//run encryption without the question in non-interactive mode if -n option is available
93-
return $this->runEncryption($input, $output);
9494
}
9595
//abort on no in interactive mode
9696
$output->writeln('aborted');

0 commit comments

Comments
 (0)