From a2dc834e1ea4b35ea9745b3b1bf28e31b26aed67 Mon Sep 17 00:00:00 2001 From: Sergey Date: Fri, 23 Feb 2018 08:54:31 +0300 Subject: [PATCH 1/2] Return status for console commands --- .../Console/Command/AbstractDependenciesCommand.php | 1 + .../Console/Command/AbstractMaintenanceCommand.php | 1 + .../Console/Command/AbstractModuleManageCommand.php | 8 +++++--- .../Setup/Console/Command/AdminUserCreateCommand.php | 1 + .../Setup/Console/Command/ConfigSetCommand.php | 1 + .../Setup/Console/Command/DbDataUpgradeCommand.php | 1 + .../Setup/Console/Command/DbSchemaUpgradeCommand.php | 2 +- .../Setup/Console/Command/DiCompileCommand.php | 6 ++++-- .../Console/Command/GenerateFixturesCommand.php | 1 + .../Console/Command/I18nCollectPhrasesCommand.php | 1 + .../Setup/Console/Command/I18nPackCommand.php | 1 + .../Setup/Console/Command/InfoAdminUriCommand.php | 1 + .../Setup/Console/Command/InfoBackupsListCommand.php | 4 +++- .../Console/Command/InfoCurrencyListCommand.php | 1 + .../Console/Command/InfoLanguageListCommand.php | 1 + .../Console/Command/InfoTimezoneListCommand.php | 1 + .../Command/InstallStoreConfigurationCommand.php | 1 + .../Console/Command/MaintenanceAllowIpsCommand.php | 1 + .../Console/Command/MaintenanceStatusCommand.php | 1 + .../Setup/Console/Command/ModuleStatusCommand.php | 1 + .../Setup/Console/Command/ModuleUninstallCommand.php | 12 ++++++------ .../Setup/Console/Command/UninstallCommand.php | 1 + 22 files changed, 36 insertions(+), 13 deletions(-) diff --git a/setup/src/Magento/Setup/Console/Command/AbstractDependenciesCommand.php b/setup/src/Magento/Setup/Console/Command/AbstractDependenciesCommand.php index f115277654fae..2c91d2d2f37c3 100644 --- a/setup/src/Magento/Setup/Console/Command/AbstractDependenciesCommand.php +++ b/setup/src/Magento/Setup/Console/Command/AbstractDependenciesCommand.php @@ -107,5 +107,6 @@ protected function execute(InputInterface $input, OutputInterface $output) // we must have an exit code higher than zero to indicate something was wrong return \Magento\Framework\Console\Cli::RETURN_FAILURE; } + return \Magento\Framework\Console\Cli::RETURN_SUCCESS; } } diff --git a/setup/src/Magento/Setup/Console/Command/AbstractMaintenanceCommand.php b/setup/src/Magento/Setup/Console/Command/AbstractMaintenanceCommand.php index ae6611273cb6b..85ae008adf366 100644 --- a/setup/src/Magento/Setup/Console/Command/AbstractMaintenanceCommand.php +++ b/setup/src/Magento/Setup/Console/Command/AbstractMaintenanceCommand.php @@ -99,6 +99,7 @@ protected function execute(InputInterface $input, OutputInterface $output) . '' ); } + return \Magento\Framework\Console\Cli::RETURN_SUCCESS; } /** diff --git a/setup/src/Magento/Setup/Console/Command/AbstractModuleManageCommand.php b/setup/src/Magento/Setup/Console/Command/AbstractModuleManageCommand.php index eab1ce79f5b3d..5d7eedfa66c2a 100644 --- a/setup/src/Magento/Setup/Console/Command/AbstractModuleManageCommand.php +++ b/setup/src/Magento/Setup/Console/Command/AbstractModuleManageCommand.php @@ -12,6 +12,7 @@ use Symfony\Component\Console\Input\InputOption; use Magento\Framework\App\DeploymentConfig; use Magento\Framework\Module\Status; +use Magento\Framework\Console\Cli; abstract class AbstractModuleManageCommand extends AbstractModuleCommand { @@ -77,14 +78,14 @@ protected function execute(InputInterface $input, OutputInterface $output) if (!empty($messages)) { $output->writeln(implode(PHP_EOL, $messages)); // we must have an exit code higher than zero to indicate something was wrong - return \Magento\Framework\Console\Cli::RETURN_FAILURE; + return Cli::RETURN_FAILURE; } try { $modulesToChange = $this->getStatus()->getModulesToChange($isEnable, $modules); } catch (\LogicException $e) { $output->writeln('' . $e->getMessage() . ''); // we must have an exit code higher than zero to indicate something was wrong - return \Magento\Framework\Console\Cli::RETURN_FAILURE; + return Cli::RETURN_FAILURE; } if (!empty($modulesToChange)) { $force = $input->getOption(self::INPUT_KEY_FORCE); @@ -96,7 +97,7 @@ protected function execute(InputInterface $input, OutputInterface $output) ); $output->writeln('' . implode("\n", $constraints) . ''); // we must have an exit code higher than zero to indicate something was wrong - return \Magento\Framework\Console\Cli::RETURN_FAILURE; + return Cli::RETURN_FAILURE; } } $this->setIsEnabled($isEnable, $modulesToChange, $output); @@ -111,6 +112,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } else { $output->writeln('No modules were changed.'); } + return Cli::RETURN_SUCCESS; } /** diff --git a/setup/src/Magento/Setup/Console/Command/AdminUserCreateCommand.php b/setup/src/Magento/Setup/Console/Command/AdminUserCreateCommand.php index 4ad8e7c229bfd..00fa272e74962 100644 --- a/setup/src/Magento/Setup/Console/Command/AdminUserCreateCommand.php +++ b/setup/src/Magento/Setup/Console/Command/AdminUserCreateCommand.php @@ -159,6 +159,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $output->writeln( 'Created Magento administrator user named ' . $input->getOption(AdminAccount::KEY_USER) . '' ); + return \Magento\Framework\Console\Cli::RETURN_SUCCESS; } /** diff --git a/setup/src/Magento/Setup/Console/Command/ConfigSetCommand.php b/setup/src/Magento/Setup/Console/Command/ConfigSetCommand.php index 4192d22524ad1..aa96e9fdc7e71 100644 --- a/setup/src/Magento/Setup/Console/Command/ConfigSetCommand.php +++ b/setup/src/Magento/Setup/Console/Command/ConfigSetCommand.php @@ -126,6 +126,7 @@ function ($value) { $output->writeln('You made no changes to the configuration.'); } } + return \Magento\Framework\Console\Cli::RETURN_SUCCESS; } /** diff --git a/setup/src/Magento/Setup/Console/Command/DbDataUpgradeCommand.php b/setup/src/Magento/Setup/Console/Command/DbDataUpgradeCommand.php index 36b010d6d1e38..ae0c2f5c4e27f 100644 --- a/setup/src/Magento/Setup/Console/Command/DbDataUpgradeCommand.php +++ b/setup/src/Magento/Setup/Console/Command/DbDataUpgradeCommand.php @@ -67,5 +67,6 @@ protected function execute(InputInterface $input, OutputInterface $output) } $installer = $this->installFactory->create(new ConsoleLogger($output)); $installer->installDataFixtures(); + return \Magento\Framework\Console\Cli::RETURN_SUCCESS; } } diff --git a/setup/src/Magento/Setup/Console/Command/DbSchemaUpgradeCommand.php b/setup/src/Magento/Setup/Console/Command/DbSchemaUpgradeCommand.php index c3b7778cdcb9d..3ef9a441b868f 100644 --- a/setup/src/Magento/Setup/Console/Command/DbSchemaUpgradeCommand.php +++ b/setup/src/Magento/Setup/Console/Command/DbSchemaUpgradeCommand.php @@ -81,6 +81,6 @@ protected function execute(InputInterface $input, OutputInterface $output) } $installer = $this->installFactory->create(new ConsoleLogger($output)); $installer->installSchema($input->getOptions()); - return null; + return \Magento\Framework\Console\Cli::RETURN_SUCCESS; } } diff --git a/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php b/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php index 904840869fdeb..ff47a13e8b5dc 100644 --- a/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php +++ b/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php @@ -21,6 +21,7 @@ use Magento\Setup\Module\Di\App\Task\OperationInterface; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Helper\ProgressBar; +use Magento\Framework\Console\Cli; /** * Command to run compile in single-tenant mode @@ -141,7 +142,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $output->writeln($line); } // we must have an exit code higher than zero to indicate something was wrong - return \Magento\Framework\Console\Cli::RETURN_FAILURE; + return Cli::RETURN_FAILURE; } $modulePaths = $this->componentRegistrar->getPaths(ComponentRegistrar::MODULE); @@ -211,8 +212,9 @@ function (OperationInterface $operation) use ($progressBar) { } catch (OperationException $e) { $output->writeln('' . $e->getMessage() . ''); // we must have an exit code higher than zero to indicate something was wrong - return \Magento\Framework\Console\Cli::RETURN_FAILURE; + return Cli::RETURN_FAILURE; } + return Cli::RETURN_SUCCESS; } /** diff --git a/setup/src/Magento/Setup/Console/Command/GenerateFixturesCommand.php b/setup/src/Magento/Setup/Console/Command/GenerateFixturesCommand.php index d4f192255c209..e084cd8ff6cad 100644 --- a/setup/src/Magento/Setup/Console/Command/GenerateFixturesCommand.php +++ b/setup/src/Magento/Setup/Console/Command/GenerateFixturesCommand.php @@ -133,6 +133,7 @@ protected function execute(InputInterface $input, OutputInterface $output) // we must have an exit code higher than zero to indicate something was wrong return \Magento\Framework\Console\Cli::RETURN_FAILURE; } + return \Magento\Framework\Console\Cli::RETURN_SUCCESS; } /** diff --git a/setup/src/Magento/Setup/Console/Command/I18nCollectPhrasesCommand.php b/setup/src/Magento/Setup/Console/Command/I18nCollectPhrasesCommand.php index 1151ba7630d5d..bb8ab4e4cc49a 100644 --- a/setup/src/Magento/Setup/Console/Command/I18nCollectPhrasesCommand.php +++ b/setup/src/Magento/Setup/Console/Command/I18nCollectPhrasesCommand.php @@ -77,5 +77,6 @@ protected function execute(InputInterface $input, OutputInterface $output) $input->getOption(self::INPUT_KEY_MAGENTO) ); $output->writeln('Dictionary successfully processed.'); + return \Magento\Framework\Console\Cli::RETURN_SUCCESS; } } diff --git a/setup/src/Magento/Setup/Console/Command/I18nPackCommand.php b/setup/src/Magento/Setup/Console/Command/I18nPackCommand.php index 0fa3f474500db..7c5cc89387dcf 100644 --- a/setup/src/Magento/Setup/Console/Command/I18nPackCommand.php +++ b/setup/src/Magento/Setup/Console/Command/I18nPackCommand.php @@ -91,5 +91,6 @@ protected function execute(InputInterface $input, OutputInterface $output) $input->getOption(self::INPUT_KEY_ALLOW_DUPLICATES) ); $output->writeln("Successfully saved $locale language package."); + return \Magento\Framework\Console\Cli::RETURN_SUCCESS; } } diff --git a/setup/src/Magento/Setup/Console/Command/InfoAdminUriCommand.php b/setup/src/Magento/Setup/Console/Command/InfoAdminUriCommand.php index 290a62d661cac..006afc27a0826 100644 --- a/setup/src/Magento/Setup/Console/Command/InfoAdminUriCommand.php +++ b/setup/src/Magento/Setup/Console/Command/InfoAdminUriCommand.php @@ -53,5 +53,6 @@ protected function execute(InputInterface $input, OutputInterface $output) . $this->deploymentConfig->get(BackendConfigOptionsList::CONFIG_PATH_BACKEND_FRONTNAME) . "\n" ); + return \Magento\Framework\Console\Cli::RETURN_SUCCESS; } } diff --git a/setup/src/Magento/Setup/Console/Command/InfoBackupsListCommand.php b/setup/src/Magento/Setup/Console/Command/InfoBackupsListCommand.php index c22367bded29a..178102aa0b3b7 100644 --- a/setup/src/Magento/Setup/Console/Command/InfoBackupsListCommand.php +++ b/setup/src/Magento/Setup/Console/Command/InfoBackupsListCommand.php @@ -87,7 +87,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } if (empty($tempTable)) { $output->writeln('No backup files found.'); - return; + return \Magento\Framework\Console\Cli::RETURN_SUCCESS; } $output->writeln("Showing backup files in $backupsDir."); /** @var \Symfony\Component\Console\Helper\Table $table */ @@ -101,5 +101,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } else { $output->writeln('No backup files found.'); } + + return \Magento\Framework\Console\Cli::RETURN_SUCCESS; } } diff --git a/setup/src/Magento/Setup/Console/Command/InfoCurrencyListCommand.php b/setup/src/Magento/Setup/Console/Command/InfoCurrencyListCommand.php index b9734807e3522..d673fc85c1ef1 100644 --- a/setup/src/Magento/Setup/Console/Command/InfoCurrencyListCommand.php +++ b/setup/src/Magento/Setup/Console/Command/InfoCurrencyListCommand.php @@ -56,5 +56,6 @@ protected function execute(InputInterface $input, OutputInterface $output) } $table->render($output); + return \Magento\Framework\Console\Cli::RETURN_SUCCESS; } } diff --git a/setup/src/Magento/Setup/Console/Command/InfoLanguageListCommand.php b/setup/src/Magento/Setup/Console/Command/InfoLanguageListCommand.php index 171ee32266a7f..88d1bdd5601d5 100644 --- a/setup/src/Magento/Setup/Console/Command/InfoLanguageListCommand.php +++ b/setup/src/Magento/Setup/Console/Command/InfoLanguageListCommand.php @@ -56,5 +56,6 @@ protected function execute(InputInterface $input, OutputInterface $output) } $table->render($output); + return \Magento\Framework\Console\Cli::RETURN_SUCCESS; } } diff --git a/setup/src/Magento/Setup/Console/Command/InfoTimezoneListCommand.php b/setup/src/Magento/Setup/Console/Command/InfoTimezoneListCommand.php index 587334a7e1dfd..2a6cc29e6c08c 100644 --- a/setup/src/Magento/Setup/Console/Command/InfoTimezoneListCommand.php +++ b/setup/src/Magento/Setup/Console/Command/InfoTimezoneListCommand.php @@ -56,5 +56,6 @@ protected function execute(InputInterface $input, OutputInterface $output) } $table->render($output); + } } diff --git a/setup/src/Magento/Setup/Console/Command/InstallStoreConfigurationCommand.php b/setup/src/Magento/Setup/Console/Command/InstallStoreConfigurationCommand.php index fdfd0af451aa2..7eb8aec274888 100644 --- a/setup/src/Magento/Setup/Console/Command/InstallStoreConfigurationCommand.php +++ b/setup/src/Magento/Setup/Console/Command/InstallStoreConfigurationCommand.php @@ -127,6 +127,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } $installer = $this->installerFactory->create(new ConsoleLogger($output)); $installer->installUserConfig($input->getOptions()); + return \Magento\Framework\Console\Cli::RETURN_SUCCESS; } /** diff --git a/setup/src/Magento/Setup/Console/Command/MaintenanceAllowIpsCommand.php b/setup/src/Magento/Setup/Console/Command/MaintenanceAllowIpsCommand.php index 5445bca8713e5..b382a45295eb6 100644 --- a/setup/src/Magento/Setup/Console/Command/MaintenanceAllowIpsCommand.php +++ b/setup/src/Magento/Setup/Console/Command/MaintenanceAllowIpsCommand.php @@ -101,6 +101,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $this->maintenanceMode->setAddresses(''); $output->writeln('Set exempt IP-addresses: none'); } + return \Magento\Framework\Console\Cli::RETURN_SUCCESS; } /** diff --git a/setup/src/Magento/Setup/Console/Command/MaintenanceStatusCommand.php b/setup/src/Magento/Setup/Console/Command/MaintenanceStatusCommand.php index 0ac8095c31c0c..f2d3d2bf30caa 100644 --- a/setup/src/Magento/Setup/Console/Command/MaintenanceStatusCommand.php +++ b/setup/src/Magento/Setup/Console/Command/MaintenanceStatusCommand.php @@ -56,5 +56,6 @@ protected function execute(InputInterface $input, OutputInterface $output) $addressInfo = $this->maintenanceMode->getAddressInfo(); $addresses = implode(' ', $addressInfo); $output->writeln('List of exempt IP-addresses: ' . ($addresses ? $addresses : 'none') . ''); + return \Magento\Framework\Console\Cli::RETURN_SUCCESS; } } diff --git a/setup/src/Magento/Setup/Console/Command/ModuleStatusCommand.php b/setup/src/Magento/Setup/Console/Command/ModuleStatusCommand.php index d4305c9572a66..85af8f3caeb1a 100644 --- a/setup/src/Magento/Setup/Console/Command/ModuleStatusCommand.php +++ b/setup/src/Magento/Setup/Console/Command/ModuleStatusCommand.php @@ -65,5 +65,6 @@ protected function execute(InputInterface $input, OutputInterface $output) } else { $output->writeln(join("\n", $disabledModules)); } + return \Magento\Framework\Console\Cli::RETURN_SUCCESS; } } diff --git a/setup/src/Magento/Setup/Console/Command/ModuleUninstallCommand.php b/setup/src/Magento/Setup/Console/Command/ModuleUninstallCommand.php index 74ec0dd41e802..6aff87995fa49 100644 --- a/setup/src/Magento/Setup/Console/Command/ModuleUninstallCommand.php +++ b/setup/src/Magento/Setup/Console/Command/ModuleUninstallCommand.php @@ -231,7 +231,7 @@ protected function execute(InputInterface $input, OutputInterface $output) 'You cannot run this command because the Magento application is not installed.' ); // we must have an exit code higher than zero to indicate something was wrong - return \Magento\Framework\Console\Cli::RETURN_FAILURE; + return Cli::RETURN_FAILURE; } $modules = $input->getArgument(self::INPUT_KEY_MODULES); @@ -249,7 +249,7 @@ protected function execute(InputInterface $input, OutputInterface $output) if (!empty($messages)) { $output->writeln($messages); // we must have an exit code higher than zero to indicate something was wrong - return \Magento\Framework\Console\Cli::RETURN_FAILURE; + return Cli::RETURN_FAILURE; } // check dependencies @@ -257,7 +257,7 @@ protected function execute(InputInterface $input, OutputInterface $output) if (!empty($dependencyMessages)) { $output->writeln($dependencyMessages); // we must have an exit code higher than zero to indicate something was wrong - return \Magento\Framework\Console\Cli::RETURN_FAILURE; + return Cli::RETURN_FAILURE; } $helper = $this->getHelper('question'); @@ -266,7 +266,7 @@ protected function execute(InputInterface $input, OutputInterface $output) false ); if (!$helper->ask($input, $output, $question) && $input->isInteractive()) { - return \Magento\Framework\Console\Cli::RETURN_FAILURE; + return Cli::RETURN_FAILURE; } $result = $this->maintenanceModeEnabler->executeInMaintenanceMode( @@ -298,11 +298,11 @@ function () use ($input, $output, $modules, $helper) { $this->moduleUninstaller->uninstallCode($output, $modules); $this->cleanup($input, $output); - return \Magento\Framework\Console\Cli::RETURN_SUCCESS; + return Cli::RETURN_SUCCESS; } catch (\Exception $e) { $output->writeln('' . $e->getMessage() . ''); $output->writeln('Please disable maintenance mode after you resolved above issues'); - return \Magento\Framework\Console\Cli::RETURN_FAILURE; + return Cli::RETURN_FAILURE; } }, $output, diff --git a/setup/src/Magento/Setup/Console/Command/UninstallCommand.php b/setup/src/Magento/Setup/Console/Command/UninstallCommand.php index f321117422adf..0163ef3846c83 100644 --- a/setup/src/Magento/Setup/Console/Command/UninstallCommand.php +++ b/setup/src/Magento/Setup/Console/Command/UninstallCommand.php @@ -50,5 +50,6 @@ protected function execute(InputInterface $input, OutputInterface $output) $installer = $this->installerFactory->create(new ConsoleLogger($output)); $installer->uninstall(); } + return \Magento\Framework\Console\Cli::RETURN_SUCCESS; } } From 50b30b3d156a3db6298de5e8810a5fa8157daac7 Mon Sep 17 00:00:00 2001 From: Sergey Date: Fri, 23 Feb 2018 17:03:14 +0300 Subject: [PATCH 2/2] Returen status for timezone list command --- .../Magento/Setup/Console/Command/InfoTimezoneListCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup/src/Magento/Setup/Console/Command/InfoTimezoneListCommand.php b/setup/src/Magento/Setup/Console/Command/InfoTimezoneListCommand.php index 2a6cc29e6c08c..95b4cd27bbd3a 100644 --- a/setup/src/Magento/Setup/Console/Command/InfoTimezoneListCommand.php +++ b/setup/src/Magento/Setup/Console/Command/InfoTimezoneListCommand.php @@ -56,6 +56,6 @@ protected function execute(InputInterface $input, OutputInterface $output) } $table->render($output); - + return \Magento\Framework\Console\Cli::RETURN_SUCCESS; } }