[ticket/12610] Improve output

PHPBB3-12610
This commit is contained in:
Tristan Darricau 2015-08-26 12:06:56 +02:00 committed by Tristan Darricau
parent 1f305e4025
commit 45dda53310
No known key found for this signature in database
GPG key ID: 817043C2E29DB881
3 changed files with 33 additions and 18 deletions

View file

@ -71,16 +71,16 @@ require($phpbb_root_path . 'includes/compatibility_globals.' . $phpEx);
register_compatibility_globals(); register_compatibility_globals();
/** @var \phpbb\language\language $language */
$language = $phpbb_container->get('language');
$language->add_lang(array('common', 'acp/common', 'cli'));
/* @var $user \phpbb\user */ /* @var $user \phpbb\user */
$user = $phpbb_container->get('user'); $user = $phpbb_container->get('user');
$user->data['user_id'] = ANONYMOUS; $user->data['user_id'] = ANONYMOUS;
$user->ip = '127.0.0.1'; $user->ip = '127.0.0.1';
$user->add_lang('acp/common');
$user->add_lang('cli');
/* @var $lang \phpbb\language\language */
$lang = $phpbb_container->get('language');
$application = new \phpbb\console\application('phpBB Console', PHPBB_VERSION, $language);
$application = new \phpbb\console\application('phpBB Console', PHPBB_VERSION, $lang); $application = new \phpbb\console\application('phpBB Console', PHPBB_VERSION, $lang);
$application->setDispatcher($phpbb_container->get('dispatcher')); $application->setDispatcher($phpbb_container->get('dispatcher'));
$application->register_container_commands($phpbb_container->get('console.command_collection')); $application->register_container_commands($phpbb_container->get('console.command_collection'));

View file

@ -50,9 +50,6 @@ $lang = array_merge($lang, array(
'CLI_DESCRIPTION_CRON_LIST' => 'Prints a list of ready and unready cron jobs.', 'CLI_DESCRIPTION_CRON_LIST' => 'Prints a list of ready and unready cron jobs.',
'CLI_DESCRIPTION_CRON_RUN' => 'Runs all ready cron tasks.', 'CLI_DESCRIPTION_CRON_RUN' => 'Runs all ready cron tasks.',
'CLI_DESCRIPTION_CRON_RUN_ARGUMENT_1' => 'Name of the task to be run', 'CLI_DESCRIPTION_CRON_RUN_ARGUMENT_1' => 'Name of the task to be run',
'CLI_DESCRIPTION_CRON_RUN_OPTION_CACHE' => 'Run check command with cache.',
'CLI_DESCRIPTION_CRON_RUN_OPTION_STABILITY' => 'Run command choosing to check only stable or unstable versions.',
'CLI_DESCRIPTION_DB_LIST' => 'List all installed and available migrations.', 'CLI_DESCRIPTION_DB_LIST' => 'List all installed and available migrations.',
'CLI_DESCRIPTION_DB_MIGRATE' => 'Updates the database by applying migrations.', 'CLI_DESCRIPTION_DB_MIGRATE' => 'Updates the database by applying migrations.',
'CLI_DESCRIPTION_DB_REVERT' => 'Revert a migration.', 'CLI_DESCRIPTION_DB_REVERT' => 'Revert a migration.',
@ -90,6 +87,8 @@ $lang = array_merge($lang, array(
'CLI_DESCRIPTION_UPDATE_CHECK' => 'Check if the board is up to date.', 'CLI_DESCRIPTION_UPDATE_CHECK' => 'Check if the board is up to date.',
'CLI_DESCRIPTION_UPDATE_CHECK_ARGUMENT_1' => 'Name of the extension to check (if all, checks all the extensions)', 'CLI_DESCRIPTION_UPDATE_CHECK_ARGUMENT_1' => 'Name of the extension to check (if all, checks all the extensions)',
'CLI_DESCRIPTION_UPDATE_CHECK_OPTION_CACHE' => 'Run check command with cache.',
'CLI_DESCRIPTION_UPDATE_CHECK_OPTION_STABILITY' => 'Run command choosing to check only stable or unstable versions.',
'CLI_ERROR_INVALID_STABILITY' => '"%s" is not a valid stability.', 'CLI_ERROR_INVALID_STABILITY' => '"%s" is not a valid stability.',

View file

@ -52,8 +52,8 @@ class check extends \phpbb\console\command\command
->setName('update:check') ->setName('update:check')
->setDescription($this->user->lang('CLI_DESCRIPTION_UPDATE_CHECK')) ->setDescription($this->user->lang('CLI_DESCRIPTION_UPDATE_CHECK'))
->addArgument('ext-name', InputArgument::OPTIONAL, $this->user->lang('CLI_DESCRIPTION_UPDATE_CHECK_ARGUMENT_1')) ->addArgument('ext-name', InputArgument::OPTIONAL, $this->user->lang('CLI_DESCRIPTION_UPDATE_CHECK_ARGUMENT_1'))
->addOption('stability', null, InputOption::VALUE_REQUIRED, 'CLI_DESCRIPTION_CRON_RUN_OPTION_STABILITY') ->addOption('stability', null, InputOption::VALUE_REQUIRED, $this->user->lang('CLI_DESCRIPTION_UPDATE_CHECK_OPTION_STABILITY'))
->addOption('cache', 'c', InputOption::VALUE_NONE, 'CLI_DESCRIPTION_CRON_RUN_OPTION_CACHE') ->addOption('cache', 'c', InputOption::VALUE_NONE, $this->user->lang('CLI_DESCRIPTION_UPDATE_CHECK_OPTION_CACHE'))
; ;
} }
@ -215,6 +215,7 @@ class check extends \phpbb\console\command\command
*/ */
protected function check_all_ext(InputInterface $input, OutputInterface $output, $stability, $recheck) protected function check_all_ext(InputInterface $input, OutputInterface $output, $stability, $recheck)
{ {
/** @var \phpbb\extension\manager $ext_manager */
$ext_manager = $this->phpbb_container->get('ext.manager'); $ext_manager = $this->phpbb_container->get('ext.manager');
$ext_name_length = max(30, strlen($this->user->lang('EXTENSION_NAME'))); $ext_name_length = max(30, strlen($this->user->lang('EXTENSION_NAME')));
@ -230,17 +231,32 @@ class check extends \phpbb\console\command\command
try try
{ {
$metadata = $md_manager->get_metadata('all'); $metadata = $md_manager->get_metadata('all');
$message .= sprintf(" | <info>%-{$current_version_length}s</info>", $metadata['version']); if (isset($metadata['extra']['version-check']))
try
{ {
try {
$updates_available = $ext_manager->version_check($md_manager, $recheck, false, $stability); $updates_available = $ext_manager->version_check($md_manager, $recheck, false, $stability);
$message .= sprintf(" | <comment>%s</comment>", implode(', ', array_keys($updates_available))); if (!empty($updates_available))
}
catch (\RuntimeException $e)
{ {
$message .= sprintf(" | <comment>%-{$current_version_length}s</comment> | %s",
$metadata['version'],
implode(', ', array_keys($updates_available))
);
}
else
{
$message .= sprintf(" | <info>%-{$current_version_length}s</info> | ",
$metadata['version']
);
}
} catch (\RuntimeException $e) {
$message .= ' | '; $message .= ' | ';
} }
} }
else
{
$message .= sprintf(" | %-{$current_version_length}s | ", $metadata['version']);
}
}
catch (exception_interface $e) catch (exception_interface $e)
{ {
$exception_message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters())); $exception_message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters()));