|
15 | 15 |
|
16 | 16 | use CodeIgniter\CLI\AbstractCommand; |
17 | 17 | use CodeIgniter\CLI\Attributes\Command; |
18 | | -use CodeIgniter\CLI\CLI; |
19 | 18 | use CodeIgniter\CLI\Input\Argument; |
20 | 19 | use CodeIgniter\CLI\Input\Option; |
| 20 | +use CodeIgniter\CLI\Output; |
21 | 21 |
|
22 | 22 | /** |
23 | 23 | * Displays the basic usage information for a given command. |
@@ -51,57 +51,57 @@ protected function execute(array $arguments, array $options): int |
51 | 51 | return EXIT_ERROR; |
52 | 52 | } |
53 | 53 |
|
54 | | - $this->describeHelp($commands->getCommand($command, legacy: false)); |
| 54 | + $this->describeHelp($commands->getCommand($command, legacy: false), $this->getOutput()); |
55 | 55 |
|
56 | 56 | return EXIT_SUCCESS; |
57 | 57 | } |
58 | 58 |
|
59 | | - private function describeHelp(AbstractCommand $command): void |
| 59 | + private function describeHelp(AbstractCommand $command, Output $output): void |
60 | 60 | { |
61 | | - CLI::write(lang('CLI.helpUsage'), 'yellow'); |
| 61 | + $output->write(lang('CLI.helpUsage'), 'yellow'); |
62 | 62 |
|
63 | 63 | foreach ($command->getUsages() as $usage) { |
64 | | - CLI::write($this->addPadding($usage)); |
| 64 | + $output->write($this->addPadding($usage)); |
65 | 65 | } |
66 | 66 |
|
67 | 67 | if ($command->getDescription() !== '') { |
68 | | - CLI::newLine(); |
69 | | - CLI::write(lang('CLI.helpDescription'), 'yellow'); |
70 | | - CLI::write($this->addPadding($command->getDescription())); |
| 68 | + $output->newLine(); |
| 69 | + $output->write(lang('CLI.helpDescription'), 'yellow'); |
| 70 | + $output->write($this->addPadding($command->getDescription())); |
71 | 71 | } |
72 | 72 |
|
73 | 73 | if ($command->getAliases() !== []) { |
74 | | - CLI::newLine(); |
75 | | - CLI::write(lang('CLI.helpAliases'), 'yellow'); |
| 74 | + $output->newLine(); |
| 75 | + $output->write(lang('CLI.helpAliases'), 'yellow'); |
76 | 76 |
|
77 | 77 | foreach ($command->getAliases() as $alias) { |
78 | | - CLI::write($this->addPadding($alias)); |
| 78 | + $output->write($this->addPadding($alias)); |
79 | 79 | } |
80 | 80 | } |
81 | 81 |
|
82 | 82 | $maxPadding = $this->getMaxPadding($command); |
83 | 83 |
|
84 | 84 | if ($command->getArgumentsDefinition() !== []) { |
85 | | - CLI::newLine(); |
86 | | - CLI::write(lang('CLI.helpArguments'), 'yellow'); |
| 85 | + $output->newLine(); |
| 86 | + $output->write(lang('CLI.helpArguments'), 'yellow'); |
87 | 87 |
|
88 | 88 | foreach ($command->getArgumentsDefinition() as $argument => $definition) { |
89 | 89 | $default = ! $definition->required && $this->shouldShowDefault($definition->default) |
90 | 90 | ? sprintf(' [default: %s]', $this->formatDefaultValue($definition->default)) |
91 | 91 | : ''; |
92 | 92 |
|
93 | | - CLI::write(sprintf( |
| 93 | + $output->write(sprintf( |
94 | 94 | '%s%s%s', |
95 | | - CLI::color($this->addPadding($argument, 2, $maxPadding), 'green'), |
| 95 | + $output->color($this->addPadding($argument, 2, $maxPadding), 'green'), |
96 | 96 | $definition->description, |
97 | | - CLI::color($default, 'yellow'), |
| 97 | + $output->color($default, 'yellow'), |
98 | 98 | )); |
99 | 99 | } |
100 | 100 | } |
101 | 101 |
|
102 | 102 | if ($command->getOptionsDefinition() !== []) { |
103 | | - CLI::newLine(); |
104 | | - CLI::write(lang('CLI.helpOptions'), 'yellow'); |
| 103 | + $output->newLine(); |
| 104 | + $output->write(lang('CLI.helpOptions'), 'yellow'); |
105 | 105 |
|
106 | 106 | $hasShortcuts = $command->getShortcuts() !== []; |
107 | 107 |
|
@@ -130,12 +130,12 @@ private function describeHelp(AbstractCommand $command): void |
130 | 130 | ? sprintf(' [default: %s]', $this->formatDefaultValue($definition->default)) |
131 | 131 | : ''; |
132 | 132 |
|
133 | | - CLI::write(sprintf( |
| 133 | + $output->write(sprintf( |
134 | 134 | '%s%s%s%s', |
135 | | - CLI::color($this->addPadding($optionString, 2, $maxPadding), 'green'), |
| 135 | + $output->color($this->addPadding($optionString, 2, $maxPadding), 'green'), |
136 | 136 | $definition->description, |
137 | | - CLI::color($default, 'yellow'), |
138 | | - $definition->isArray ? CLI::color(' (multiple values allowed)', 'yellow') : '', |
| 137 | + $output->color($default, 'yellow'), |
| 138 | + $definition->isArray ? $output->color(' (multiple values allowed)', 'yellow') : '', |
139 | 139 | )); |
140 | 140 | } |
141 | 141 | } |
|
0 commit comments