Install.php 990 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. declare (strict_types=1);
  3. namespace app\command\Addon;
  4. use app\service\core\addon\CoreAddonInstallService;
  5. use Exception;
  6. use think\console\Command;
  7. use think\console\Input;
  8. use think\console\input\Option;
  9. use think\console\Output;
  10. class Install extends Command
  11. {
  12. protected function configure()
  13. {
  14. // 指令配置
  15. $this->setName('addon:install')
  16. ->addArgument('addon', Option::VALUE_REQUIRED)
  17. ->addOption('step', 's', Option::VALUE_REQUIRED)
  18. ->setDescription('the addon install command');
  19. }
  20. protected function execute(Input $input, Output $output)
  21. {
  22. $instance = CoreAddonInstallService::instance($input->getArgument('addon'));
  23. $step = $input->getOption('step');
  24. try {
  25. $instance->$step();
  26. $output->writeln("Command executed successfully");
  27. } catch ( Exception $e ) {
  28. $output->writeln("Command failed " . $e->getMessage());
  29. }
  30. }
  31. }