コード例 #1
0
ファイル: Command.php プロジェクト: nimbly/minion
 /**
  * @param Context $context
  *
  * @return CommandInterface
  * @throws \Exception
  */
 public static function run(Context $context)
 {
     Console::getInstance()->backgroundLightGreen()->white()->out("Running <bold>{$context->command}</bold> command");
     $commandClass = "\\minion\\commands\\" . ucwords(strtolower($context->command)) . "Command";
     if (class_exists($commandClass) === false) {
         throw new \Exception("Unknown command {$context->command}");
     }
     /** @var CommandInterface $command */
     $command = new $commandClass();
     // Check for run method
     if (method_exists($command, 'run') === false) {
         throw new \Exception("Command {$context->command} run method does not exist");
     }
     return $command->run($context);
 }
コード例 #2
0
ファイル: App.php プロジェクト: nimbly/minion
 public function run(array $arguments)
 {
     // read version from command line
     $this->version = file_get_contents(__DIR__ . '/../VERSION');
     $startTime = microtime(true);
     // Build the environment object. This object gets passed all the way through the stack.
     try {
         Console::getInstance()->backgroundDarkGray()->brightBlue("# minion // v{$this->version} #");
         $this->context = new Context($arguments);
         Command::run($this->context);
     } catch (\Exception $e) {
         Console::getInstance()->backgroundRed()->white("[ERROR] {$e->getMessage()}");
         //echo("[ERROR] {$e->getMessage()}\n");
     }
     Console::getInstance()->backgroundDarkGray()->brightBlue("# minion completed #");
     //Console::getInstance()->lightGray('time='.round(microtime(true) - $startTime, 3).'s');
 }
コード例 #3
0
ファイル: LocalConnection.php プロジェクト: nimbly/minion
 public function execute($command, $showCommand = false, $showResponse = false)
 {
     if ($showCommand) {
         Console::getInstance()->inline("\tExecuting <bold>{$command}</bold> ");
     }
     $response = system($command, $status);
     if ($status) {
         Console::getInstance()->backgroundRed()->brightWhite("FAILED!");
         throw new \Exception($response);
     }
     if ($showCommand) {
         Console::getInstance()->bold()->out('OK');
     }
     if ($showResponse) {
         Console::getInstance()->backgroundWhite()->blue(trim($response));
     }
     return $response;
 }
コード例 #4
0
ファイル: Task.php プロジェクト: nimbly/minion
 /**
  * @param $task
  * @param Context $context
  * @param Environment $environment
  * @param ConnectionInterface|null $connection
  *
  * @return mixed
  * @throws \Exception
  */
 public static function run($task, Context $context, Environment $environment, ConnectionInterface $connection = null)
 {
     Console::getInstance()->green()->out("* Running <bold><white>" . trim($task) . "</white></bold> task");
     // Normalize task class name
     $task = ucfirst(strtolower(trim($task)));
     // What task are we running?
     $taskClass = "\\minion\\tasks\\{$task}Task";
     if (class_exists($taskClass) == false) {
         throw new \Exception("Task {$taskClass} was not found.");
     }
     /** @var TaskInterface $task */
     $task = new $taskClass();
     // Check for run method
     if (method_exists($task, 'run') === false) {
         throw new \Exception("Task {$task} run method does not exist");
     }
     return $task->run($context, $environment, $connection);
 }
コード例 #5
0
ファイル: Context.php プロジェクト: nimbly/minion
 public function say($message)
 {
     Console::getInstance()->comment($message);
 }