This commit is contained in:
2020-12-15 14:04:02 +08:00
parent c2d9250be9
commit a37df0ce7a
16 changed files with 225 additions and 162 deletions
+4 -6
View File
@@ -8,8 +8,6 @@ use Exception;
use Snowflake\Abstracts\Component;
use Snowflake\Abstracts\Input;
use Snowflake\Snowflake;
use Swoole\Coroutine;
use Swoole\Coroutine\Channel;
/**
* Class AbstractConsole
@@ -46,7 +44,7 @@ abstract class AbstractConsole extends Component
* @param Input $input
* @return $this
*/
public function setParameters(Input $input)
public function setParameters(Input $input): static
{
$this->parameters = $input;
return $this;
@@ -56,7 +54,7 @@ abstract class AbstractConsole extends Component
* @param Command $command
* @return mixed
*/
public function execCommand(Command $command)
public function execCommand(Command $command): mixed
{
return $command->onHandler($this->parameters);
}
@@ -64,7 +62,7 @@ abstract class AbstractConsole extends Component
/**
* @return Command|null
*/
public function search()
public function search(): ?Command
{
$name = $this->parameters->getCommandName();
$this->parameters->set('commandList', $this->getCommandList());
@@ -132,7 +130,7 @@ abstract class AbstractConsole extends Component
/**
* @return array
*/
private function getCommandList()
private function getCommandList(): array
{
$_tmp = [];
foreach ($this->commands as $command) {
+2 -2
View File
@@ -19,7 +19,7 @@ abstract class Command extends BaseObject implements CommandInterface
* @return string
* 返回执行的命令名称
*/
public function getName()
public function getName(): string
{
return $this->command;
}
@@ -30,7 +30,7 @@ abstract class Command extends BaseObject implements CommandInterface
*
* 返回命令描述
*/
public function getDescription()
public function getDescription(): string
{
return $this->description;
}
+5 -1
View File
@@ -16,7 +16,11 @@ class DefaultCommand extends Command
public string $description = 'help';
public function onHandler(Input $dtl)
/**
* @param Input $dtl
* @return string
*/
public function onHandler(Input $dtl): string
{
$param = $dtl->get('commandList');