/** * Execute the login via email/password * * @param string $email Email address associated with a Pantheon account * @param string $password Password for the account * @return bool True if login succeeded * @throws TerminusException */ public function logInViaUsernameAndPassword($email, $password) { if (!Terminus\Utils\isValidEmail($email)) { throw new TerminusException('{email} is not a valid email address.', compact('email'), 1); } $options = array('form_params' => array('email' => $email, 'password' => $password)); $response = $this->request->request('login', '', '', 'POST', $options); if ($response['status_code'] != '200') { throw new TerminusException('Login unsuccessful for {email}', compact('email'), 1); } $this->logger->info('Logged in as {uuid}.', array('uuid' => $response['data']->user_id)); $this->setInstanceData($response['data']); return true; }
/** * Runs a command * * @param array $args The non hyphenated (--) terms from the CL * @param array $assoc_args The hyphenated terms from the CL * @return void */ public function runCommand($args, $assoc_args = array()) { try { /** @var \Terminus\Dispatcher\RootCommand $command */ list($command, $final_args, $cmd_path) = $this->findCommandToRun($args); $name = implode(' ', $cmd_path); $command->invoke($final_args, $assoc_args); } catch (\Exception $e) { if (method_exists($e, 'getReplacements')) { $this->logger->error($e->getMessage(), $e->getReplacements()); } else { $this->logger->error($e->getMessage()); } exit(1); } }
/** * Runs a command * * @return void */ private function runCommand() { $args = $this->arguments; $assoc_args = $this->assoc_args; try { /** @var \Terminus\Dispatcher\RootCommand $command */ list($command, $final_args, $cmd_path) = $this->findCommandToRun($args); $name = implode(' ', $cmd_path); $return = $command->invoke($final_args, $assoc_args); if (is_string($return)) { self::$logger->info($return); } } catch (\Exception $e) { if (method_exists($e, 'getReplacements')) { self::$logger->error($e->getMessage(), $e->getReplacements()); } else { self::$logger->error($e->getMessage()); } exit($e->getCode()); } }