2020-08-31 01:27:08 +08:00
|
|
|
<?php
|
|
|
|
|
|
2020-10-29 18:17:25 +08:00
|
|
|
declare(strict_types=1);
|
2020-08-31 01:27:08 +08:00
|
|
|
|
2020-09-03 00:15:57 +08:00
|
|
|
namespace Console;
|
2020-08-31 01:27:08 +08:00
|
|
|
|
2020-09-07 18:11:36 +08:00
|
|
|
use Snowflake\Abstracts\Input;
|
|
|
|
|
|
2020-08-31 01:27:08 +08:00
|
|
|
/**
|
|
|
|
|
* Class DefaultCommand
|
2020-09-03 00:15:57 +08:00
|
|
|
* @package Console
|
2020-08-31 01:27:08 +08:00
|
|
|
*/
|
|
|
|
|
class DefaultCommand extends Command
|
|
|
|
|
{
|
2021-02-22 11:58:41 +08:00
|
|
|
public string $command = 'system:help';
|
2020-08-31 01:27:08 +08:00
|
|
|
|
2021-02-22 11:57:49 +08:00
|
|
|
public string $description = 'command lists';
|
2020-08-31 01:27:08 +08:00
|
|
|
|
2020-12-15 14:04:02 +08:00
|
|
|
/**
|
|
|
|
|
* @param Input $dtl
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
public function onHandler(Input $dtl): string
|
2020-08-31 01:27:08 +08:00
|
|
|
{
|
|
|
|
|
$param = $dtl->get('commandList');
|
|
|
|
|
|
|
|
|
|
$last = '';
|
2021-02-22 11:52:11 +08:00
|
|
|
$lists = ["Commands\t" . '注释'];
|
2020-08-31 01:27:08 +08:00
|
|
|
foreach ($param as $key => $val) {
|
|
|
|
|
$split = explode(':', $key);
|
|
|
|
|
if (empty($last) && isset($split[0])) {
|
2021-02-22 11:52:11 +08:00
|
|
|
$lists[] = "\033[32;40;1;1m" . $split[0] . " \033[0m\t";
|
2020-08-31 01:27:08 +08:00
|
|
|
} else if (isset($split[0]) && $last != $split[0]) {
|
2021-02-22 11:52:11 +08:00
|
|
|
$lists[] = "\033[32;40;1;1m" . $split[0] . " \033[0m\t";
|
2020-08-31 01:27:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$last = $split[0] ?? '';
|
|
|
|
|
|
|
|
|
|
list($method, $ts) = $val;
|
2021-02-22 11:52:40 +08:00
|
|
|
$lists[] = "\033[32;40;1;1m " . $key . " \033[0m\t\t" . $method."\t";
|
2020-08-31 01:27:08 +08:00
|
|
|
}
|
2021-02-22 11:45:42 +08:00
|
|
|
return implode(PHP_EOL, $lists);
|
2020-08-31 01:27:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|