|
14 | 14 |
|
15 | 15 | use Symfony\Component\Console\Input\InputInterface; |
16 | 16 | use Symfony\Component\Console\Output\OutputInterface; |
| 17 | +use Symfony\Component\Console\Style\SymfonyStyle; |
17 | 18 |
|
18 | 19 | class cron_list extends \phpbb\console\command\command |
19 | 20 | { |
@@ -55,57 +56,39 @@ protected function configure() |
55 | 56 | */ |
56 | 57 | protected function execute(InputInterface $input, OutputInterface $output) |
57 | 58 | { |
| 59 | + $io = new SymfonyStyle($input, $output); |
| 60 | + |
58 | 61 | $tasks = $this->cron_manager->get_tasks(); |
59 | 62 |
|
60 | 63 | if (empty($tasks)) |
61 | 64 | { |
62 | | - $output->writeln($this->user->lang('CRON_NO_TASKS')); |
| 65 | + $io->error($this->user->lang('CRON_NO_TASKS')); |
63 | 66 | return; |
64 | 67 | } |
65 | 68 |
|
66 | | - $ready_tasks = array(); |
67 | | - $not_ready_tasks = array(); |
| 69 | + $ready_tasks = $not_ready_tasks = array(); |
68 | 70 | foreach ($tasks as $task) |
69 | 71 | { |
70 | 72 | if ($task->is_ready()) |
71 | 73 | { |
72 | | - $ready_tasks[] = $task; |
| 74 | + $ready_tasks[] = $task->get_name(); |
73 | 75 | } |
74 | 76 | else |
75 | 77 | { |
76 | | - $not_ready_tasks[] = $task; |
| 78 | + $not_ready_tasks[] = $task->get_name(); |
77 | 79 | } |
78 | 80 | } |
79 | 81 |
|
80 | 82 | if (!empty($ready_tasks)) |
81 | 83 | { |
82 | | - $output->writeln('<info>' . $this->user->lang('TASKS_READY') . '</info>'); |
83 | | - $this->print_tasks_names($ready_tasks, $output); |
84 | | - } |
85 | | - |
86 | | - if (!empty($ready_tasks) && !empty($not_ready_tasks)) |
87 | | - { |
88 | | - $output->writeln(''); |
| 84 | + $io->section($this->user->lang('TASKS_READY')); |
| 85 | + $io->listing($ready_tasks); |
89 | 86 | } |
90 | 87 |
|
91 | 88 | if (!empty($not_ready_tasks)) |
92 | 89 | { |
93 | | - $output->writeln('<info>' . $this->user->lang('TASKS_NOT_READY') . '</info>'); |
94 | | - $this->print_tasks_names($not_ready_tasks, $output); |
95 | | - } |
96 | | - } |
97 | | - |
98 | | - /** |
99 | | - * Print a list of cron jobs |
100 | | - * |
101 | | - * @param array $tasks A list of task to display |
102 | | - * @param OutputInterface $output An OutputInterface instance |
103 | | - */ |
104 | | - protected function print_tasks_names(array $tasks, OutputInterface $output) |
105 | | - { |
106 | | - foreach ($tasks as $task) |
107 | | - { |
108 | | - $output->writeln($task->get_name()); |
| 90 | + $io->section($this->user->lang('TASKS_NOT_READY')); |
| 91 | + $io->listing($not_ready_tasks); |
109 | 92 | } |
110 | 93 | } |
111 | 94 | } |
0 commit comments