1313use Symfony \Component \Console \Command \Command ;
1414use Symfony \Component \Console \Helper \QuestionHelper ;
1515use Symfony \Component \Console \Input \InputInterface ;
16+ use Symfony \Component \Console \Input \InputOption ;
1617use Symfony \Component \Console \Output \OutputInterface ;
1718use 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