1616use Throwable ;
1717
1818/**
19- * Class BaseCommand
19+ * BaseCommand is the base class used in creating CLI commands.
20+ *
21+ * @property string $group
22+ * @property string $name
23+ * @property string $usage
24+ * @property string $description
25+ * @property array $options
26+ * @property array $arguments
27+ * @property LoggerInterface $logger
28+ * @property Commands $commands
2029 */
2130abstract class BaseCommand
2231{
@@ -78,7 +87,6 @@ abstract class BaseCommand
7887 */
7988 protected $ commands ;
8089
81- //--------------------------------------------------------------------
8290 /**
8391 * BaseCommand constructor.
8492 *
@@ -91,8 +99,6 @@ public function __construct(LoggerInterface $logger, Commands $commands)
9199 $ this ->commands = $ commands ;
92100 }
93101
94- //--------------------------------------------------------------------
95-
96102 /**
97103 * Actually execute a command.
98104 * This has to be over-ridden in any concrete implementation.
@@ -101,8 +107,6 @@ public function __construct(LoggerInterface $logger, Commands $commands)
101107 */
102108 abstract public function run (array $ params );
103109
104- //--------------------------------------------------------------------
105-
106110 /**
107111 * Can be used by a command to run other commands.
108112 *
@@ -117,8 +121,6 @@ protected function call(string $command, array $params = [])
117121 return $ this ->commands ->run ($ command , $ params );
118122 }
119123
120- //--------------------------------------------------------------------
121-
122124 /**
123125 * A simple method to display an error with line/file, in child commands.
124126 *
@@ -132,8 +134,6 @@ protected function showError(Throwable $e)
132134 require APPPATH . 'Views/errors/cli/error_exception.php ' ;
133135 }
134136
135- //--------------------------------------------------------------------
136-
137137 /**
138138 * Show Help includes (Usage, Arguments, Description, Options).
139139 */
@@ -189,8 +189,6 @@ public function showHelp()
189189 }
190190 }
191191
192- //--------------------------------------------------------------------
193-
194192 /**
195193 * Pads our string out so that all titles are the same length to nicely line up descriptions.
196194 *
@@ -208,8 +206,6 @@ public function setPad(string $item, int $max, int $extra = 2, int $indent = 0):
208206 return str_pad (str_repeat (' ' , $ indent ) . $ item , $ max );
209207 }
210208
211- //--------------------------------------------------------------------
212-
213209 /**
214210 * Get pad for $key => $value array output
215211 *
@@ -225,15 +221,15 @@ public function setPad(string $item, int $max, int $extra = 2, int $indent = 0):
225221 public function getPad (array $ array , int $ pad ): int
226222 {
227223 $ max = 0 ;
224+
228225 foreach (array_keys ($ array ) as $ key )
229226 {
230227 $ max = max ($ max , strlen ($ key ));
231228 }
229+
232230 return $ max + $ pad ;
233231 }
234232
235- //--------------------------------------------------------------------
236-
237233 /**
238234 * Makes it simple to access our protected properties.
239235 *
@@ -251,8 +247,6 @@ public function __get(string $key)
251247 return null ;
252248 }
253249
254- //--------------------------------------------------------------------
255-
256250 /**
257251 * Makes it simple to check our protected properties.
258252 *
0 commit comments