diff --git a/app/Console/Plugin/AbstractPlugin.php b/app/Console/Plugin/AbstractPlugin.php index 28a3381..1cb3955 100644 --- a/app/Console/Plugin/AbstractPlugin.php +++ b/app/Console/Plugin/AbstractPlugin.php @@ -4,10 +4,9 @@ use Inhere\Console\Application; use Inhere\Console\GlobalOption; -use Inhere\Console\IO\Input; +use Inhere\Console\IO\Output; use Toolkit\PFlag\Flags; use Toolkit\PFlag\FlagsParser; -use Toolkit\PFlag\SFlags; use Toolkit\Stdlib\Helper\DataHelper; use function array_merge; @@ -26,22 +25,22 @@ abstract class AbstractPlugin implements PluginInterface /** * @var string */ - protected $name = ''; + protected string $name = ''; /** * @var string */ - protected $filepath = ''; + protected string $filepath = ''; /** * @var string */ - protected $classname = ''; + protected string $classname = ''; /** * @var array */ - protected $metadata = []; + protected array $metadata = []; public function init(): void { @@ -93,15 +92,6 @@ protected function createFlags(): FlagsParser return $this->fs; } - /** - * @return SFlags - */ - // protected function createSFlags(): SFlags - // { - // $this->fs = new SFlags(); - // return $this->fs; - // } - /** * Metadata for the plugin * @@ -169,7 +159,6 @@ final public function getOptions(): array public function getSimpleInfo(): array { // $meta = $this->metadata(); - return [ 'name' => $this->name, // 'desc' => $meta['desc'] ?? '', @@ -180,20 +169,6 @@ public function getSimpleInfo(): array ]; } - /** - * @param Application $app - * @param array $args - */ - public function run(Application $app, array $args = []): void - { - $input = $app->getInput(); - if (!$this->beforeRun($app, $args)) { - return; - } - - $this->exec($app, $input); - } - /** * @param Application $app * @param array $args @@ -216,9 +191,22 @@ protected function beforeRun(Application $app, array $args): bool /** * @param Application $app - * @param Input $input + * @param array $args + */ + public function run(Application $app, array $args = []): void + { + if (!$this->beforeRun($app, $args)) { + return; + } + + $this->exec($app, $app->getOutput()); + } + + /** + * @param Application $app + * @param Output $output */ - abstract public function exec(Application $app, Input $input): void; + abstract public function exec(Application $app, Output $output): void; /** * @return string diff --git a/plugin/AddCommentsToJson5.php b/plugin/AddCommentsToJson5.php index 6eb0905..a521820 100644 --- a/plugin/AddCommentsToJson5.php +++ b/plugin/AddCommentsToJson5.php @@ -1,7 +1,7 @@ fs->getOpt('map-file'); $this->loadMapData($mapFile); diff --git a/plugin/demo-plugin.php b/plugin/demo-plugin.php index da8cbea..a1badeb 100644 --- a/plugin/demo-plugin.php +++ b/plugin/demo-plugin.php @@ -1,7 +1,7 @@