diff --git a/kiri-console/AbstractConsole.php b/kiri-console/AbstractConsole.php deleted file mode 100644 index a56f3235..00000000 --- a/kiri-console/AbstractConsole.php +++ /dev/null @@ -1,156 +0,0 @@ -_config = $config; - $this->signCommand(Kiri::createObject(DefaultCommand::class)); - - parent::__construct($config); - } - - /** - * @param Input $input - * @return $this - */ - public function setParameters(Input $input): static - { - $this->parameters = $input; - return $this; - } - - /** - * @param Command $command - * @return mixed - * @throws Exception - */ - public function exec(Command $command): mixed - { - fire(new OnBeforeCommandExecute()); - - $data = $command->onHandler($this->parameters); - - fire(new OnAfterCommandExecute($data)); - - return $data; - } - - /** - * @return Command|null - */ - public function search(): ?Command - { - $name = $this->parameters->getCommandName(); - $this->parameters->set('commandList', $this->getCommandList()); - - $help = 'system:help'; - foreach ($this->commands as $command) { - if ($command->command == $help) { - $help = $command; - } - if ($command->command != $name) { - continue; - } - return $command; - } - if (is_object($help)) { - return $help; - } - return null; - } - - /** - * @param Command $abstractConsole - * - * 注册命令 - */ - public function signCommand(Command $abstractConsole) - { - $this->commands[] = $abstractConsole; - } - - /** - * @param $kernel - * @throws Exception - */ - public function batch($kernel) - { - if (is_object($kernel)) { - if (!property_exists($kernel, 'commands')) { - return; - } - $kernel = $kernel->commands; - } - if (!is_array($kernel)) { - return; - } - foreach ($kernel as $command) { - $this->signCommand(Kiri::createObject($command)); - } - } - - /** - * @param Command $abstractConsole - * 释放一个命令 - */ - public function destroyCommand(Command $abstractConsole) - { - foreach ($this->commands as $index => $command) { - if ($abstractConsole === $command) { - unset($this->commands[$index]); - break; - } - } - } - - /** - * @return array - */ - private function getCommandList(): array - { - $_tmp = []; - foreach ($this->commands as $command) { - if ($command->command === 'system:help') { - continue; - } - $_tmp[$command->command] = [$command->description, $command]; - } - ksort($_tmp, SORT_ASC); - return $_tmp; - } - - -} diff --git a/kiri-console/Command.php b/kiri-console/Command.php deleted file mode 100644 index 30311706..00000000 --- a/kiri-console/Command.php +++ /dev/null @@ -1,87 +0,0 @@ -command; - } - - - /** - * @return string - * - * 返回命令描述 - */ - public function getDescription(): string - { - return $this->description; - } - - - /** - * @param $name - * @return mixed - * @throws NotFindClassException - * @throws ReflectionException - * @throws Exception - */ - public function __get($name): mixed - { - if ($this->has($name)) { - return $this->get($name); - } - return parent::__get($name); // TODO: Change the autogenerated stub - } - - - /** - * @param $name - * @return bool - * @throws - */ - private function has($name): bool - { - return Kiri::app()->has($name); - } - - - /** - * @param $name - * @return mixed - * @throws ReflectionException - * @throws NotFindClassException - */ - private function get($name): mixed - { - return Kiri::app()->get($name); - } - - -} diff --git a/kiri-console/CommandInterface.php b/kiri-console/CommandInterface.php deleted file mode 100644 index 65d0ea64..00000000 --- a/kiri-console/CommandInterface.php +++ /dev/null @@ -1,18 +0,0 @@ -signCommand($class); - } - -} diff --git a/kiri-console/ConsoleProviders.php b/kiri-console/ConsoleProviders.php deleted file mode 100644 index 6663f662..00000000 --- a/kiri-console/ConsoleProviders.php +++ /dev/null @@ -1,28 +0,0 @@ -set('console', ['class' => Console::class]); - } - - -} diff --git a/kiri-console/DefaultCommand.php b/kiri-console/DefaultCommand.php deleted file mode 100644 index 6dde37ea..00000000 --- a/kiri-console/DefaultCommand.php +++ /dev/null @@ -1,45 +0,0 @@ -get('commandList'); - - $last = ''; - $lists = ["Commands\t" . '注释']; - foreach ($param as $key => $val) { - $split = explode(':', $key); - if (empty($last) && isset($split[0])) { - $lists[] = "\033[32;40;1;1m" . $split[0] . " \033[0m\t"; - } else if (isset($split[0]) && $last != $split[0]) { - $lists[] = "\033[32;40;1;1m" . $split[0] . " \033[0m\t"; - } - - $last = $split[0] ?? ''; - - list($method, $ts) = $val; - $lists[] = "\033[32;40;1;1m " . $key . " \033[0m\t\t" . $method."\t"; - } - return implode(PHP_EOL, $lists); - } - -} diff --git a/kiri-console/ICommand.php b/kiri-console/ICommand.php deleted file mode 100644 index 9219b431..00000000 --- a/kiri-console/ICommand.php +++ /dev/null @@ -1,14 +0,0 @@ -