protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln("Hello Terra!");
     // If there are no apps, return
     if (count($this->getApplication()->getTerra()->getConfig()->get('apps')) == 0) {
         $output->writeln("<comment>There are no apps!</comment>");
         $output->writeln("Use the command <info>terra app:add</info> to add your first app.");
         return;
     }
     $helper = $this->getHelper('question');
     $app_name = $input->getArgument('app_name');
     $environment_name = $input->getArgument('environment_name');
     // If no name specified provide options
     if (empty($app_name)) {
         $question = new ChoiceQuestion('Which app? ', array_keys($this->getApplication()->getTerra()->getConfig()->get('apps')), NULL);
         $app_name = $helper->ask($input, $output, $question);
     }
     $app = $this->getApplication()->getTerra()->getConfig()->get('apps', $app_name);
     // If no environments:
     if (count($app['environments']) == 0) {
         $output->writeln("<comment>There are no environments!</comment>");
         $output->writeln("Use the command <info>terra environment:add</info> to add your first environment.");
         return;
     }
     // If no environment name specified provide options
     if (empty($environment_name)) {
         $question = new ChoiceQuestion('Which environment? ', array_keys($app['environments']), NULL);
         $environment_name = $helper->ask($input, $output, $question);
     }
     $environment = $app['environments'][$environment_name];
     $environment_factory = new EnvironmentFactory($environment, $app);
     $environment['scale'] = $environment_factory->getScale();
     $environment['url'] .= PHP_EOL . 'http://' . $environment_factory->getUrl();
     $table = $this->getHelper('table');
     $table->setHeaders(array('Name', 'Code Path', 'URL', 'Version', 'Scale'));
     $rows = array($environment);
     $table->setRows($rows);
     $table->render($output);
     $output->writeln("Docker Compose Path: " . $environment_factory->getDockerComposePath());
 }
Beispiel #2
0
 /**
  * Outputs the status of an environment.
  *
  * @param \Symfony\Component\Console\Input\InputInterface   $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  * @param $app
  * @param $environment
  *
  */
 protected function environmentStatus(InputInterface $input, OutputInterface $output)
 {
     // If there are no apps, return
     if (count($this->getApplication()->getTerra()->getConfig()->get('apps')) == 0) {
         $output->writeln('<comment>There are no apps!</comment>');
         $output->writeln('Use the command <info>terra app:add</info> to add your first app.');
         return;
     }
     $app_name = $input->getArgument('app_name');
     $environment_name = $input->getArgument('environment_name');
     $app = $this->getApplication()->getTerra()->getConfig()->get('apps', $app_name);
     // If no environments:
     if (count($app['environments']) == 0) {
         $output->writeln('<comment>There are no environments!</comment>');
         $output->writeln('Use the command <info>terra environment:add</info> to add your first environment.');
         return;
     }
     // If no environment by that name...
     if (!isset($app['environments'][$environment_name])) {
         $output->writeln("<error>There is no environment named {$environment_name} in the app {$app_name}</error>");
         return;
     }
     $environment = $app['environments'][$environment_name];
     $environment_factory = new EnvironmentFactory($environment, $app);
     $environment['scale'] = $environment_factory->getScale();
     $environment['url'] = 'http://' . $environment_factory->getHost() . ':' . $environment_factory->getPort();
     $environment['url'] .= PHP_EOL . 'http://' . $environment_factory->getUrl();
     $table = $this->getHelper('table');
     $table->setHeaders(array('Name', 'Code Path', 'docroot', 'URLs', 'Version', 'Scale'));
     $rows = array($environment);
     $table->setRows($rows);
     $table->render($output);
     $output->writeln('Docker Compose Path: ' . $environment_factory->getDockerComposePath());
 }