protected function execute(InputInterface $input, OutputInterface $output) { $output->writeln('Hello Terra!'); // Ask for an app and environment. $this->getApp($input, $output); $this->getEnvironment($input, $output); $environment_name = $this->environment->name; $app_name = $this->app->name; $environment_factory = new EnvironmentFactory($this->environment, $this->app); $environment_factory->writeConfig(); $current_scale = $environment_factory->getScale(); $output->writeln("Scaling Environment <comment>{$app_name} {$environment_name}</comment>..."); $output->writeln("Current scale: <comment>{$current_scale}</comment>"); // If no scale ask for scale. if (empty($scale)) { $question = new Question('How many app containers? '); $helper = $this->getHelper('question'); $scale = $helper->ask($input, $output, $question); } $output->writeln("Target scale: <comment>{$scale}</comment>"); $environment_factory->scale($scale); $output->writeln("Environment <comment>{$app_name} {$environment_name}</comment> scaled to <info>{$scale}</info>"); // Output the new URL. $local_url = 'http://' . $environment_factory->getHost() . ':' . $environment_factory->getPort(); $output->writeln('<info>Environment enabled!</info> Available at http://' . $environment_factory->getUrl() . ' and ' . $local_url); }
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'); $scale = $input->getArgument('scale'); // 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 (empty($app)) { $output->writeln('<error>No app by that name!</error>'); $output->writeln('Use the command <info>terra app:add</info> to add your first app.'); return; } // 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); } $app = $this->getApplication()->getTerra()->getConfig()->get('apps', $app_name); $environment = $app['environments'][$environment_name]; $environment_factory = new EnvironmentFactory($environment, $app); $environment_factory->writeConfig(); $current_scale = $environment_factory->getScale(); $output->writeln("Scaling Environment <comment>{$app_name} {$environment_name}</comment>..."); $output->writeln("Current scale: <comment>{$current_scale}</comment>"); // If no scale ask for scale. if (empty($scale)) { $question = new Question('How many app containers? '); $scale = $helper->ask($input, $output, $question); } $output->writeln("Target scale: <comment>{$scale}</comment>"); $environment_factory->scale($scale); $output->writeln("Environment <comment>{$app_name} {$environment_name}</comment> scaled to <info>{$scale}</info>"); }