protected function selectApp(InputInterface $input)
    {
        $appName = $input->getOption('app');
        if ($appName) {
            return $appName;
        }

        try {
            $apps = array_map(function (WebApp $app) {
                return $app->name;
            }, $this->api()->getCurrentDeployment($this->getSelectedEnvironment())->webapps);
            if (!count($apps)) {
                return null;
            }
        } catch (EnvironmentStateException $e) {
            if (!$e->getEnvironment()->isActive()) {
                throw new EnvironmentStateException(
                    sprintf('Could not find applications: the environment "%s" is not currently active.', $e->getEnvironment()->id),
                    $e->getEnvironment()
                );
            }
            throw $e;
        }

        $this->debug('Found app(s): ' . implode(',', $apps));
        if (count($apps) === 1) {
            $appName = reset($apps);
        } elseif ($input->isInteractive()) {
            /** @var \Platformsh\Cli\Service\QuestionHelper $questionHelper */
            $questionHelper = $this->getService('question_helper');
            $choices = array_combine($apps, $apps);
            $appName = $questionHelper->choose($choices, 'Enter a number to choose an app:');
        }

        $input->setOption('app', $appName);

        return $appName;
    }
protected function selectApp(InputInterface $input)
    {
        $appName = $input->getOption('app');
        if ($appName) {
            return $appName;
        }

        try {
            $apps = array_map(function (WebApp $app) {
                return $app->name;
            }, $this->api()->getCurrentDeployment($this->getSelectedEnvironment())->webapps);
            if (!count($apps)) {
                return null;
            }
        } catch (EnvironmentStateException $e) {
            if (!$e->getEnvironment()->isActive()) {
                throw new EnvironmentStateException(
                    sprintf('Could not find applications: the environment "%s" is not currently active.', $e->getEnvironment()->id),
                    $e->getEnvironment()
                );
            }
            throw $e;
        }

        $this->debug('Found app(s): ' . implode(',', $apps));
        if (count($apps) === 1) {
            $appName = reset($apps);
        } elseif ($input->isInteractive()) {
            /** @var \Platformsh\Cli\Service\QuestionHelper $questionHelper */
            $questionHelper = $this->getService('question_helper');
            $choices = array_combine($apps, $apps);
            $appName = $questionHelper->choose($choices, 'Enter a number to choose an app:');
        }

        $input->setOption('app', $appName);

        return $appName;
    }
protected function selectApp ( InputInterface $ input ) { $ appName = $ input -> getOption ( 'app' ) ; if ( $ appName ) { return $ appName ; } try { $ apps = array_map ( function ( WebApp $ app ) { return $ app -> name ; } , $ this -> api ( ) -> getCurrentDeployment ( $ this -> getSelectedEnvironment ( ) ) -> webapps ) ; if ( ! count ( $ apps ) ) { return null ; } } catch ( EnvironmentStateException $ e ) { if ( ! $ e -> getEnvironment ( ) -> isActive ( ) ) { throw new EnvironmentStateException ( sprintf ( 'Could not find applications: the environment "%s" is not currently active.' , $ e -> getEnvironment ( ) -> id ) , $ e -> getEnvironment ( ) ) ; } throw $ e ; } $ this -> debug ( 'Found app(s): ' . implode ( ',' , $ apps ) ) ; if ( count ( $ apps ) === 1 ) { $ appName = reset ( $ apps ) ; } elseif ( $ input -> isInteractive ( ) ) { /** @var \Platformsh\Cli\Service\QuestionHelper $questionHelper */ $ questionHelper = $ this -> getService ( 'question_helper' ) ; $ choices = array_combine ( $ apps , $ apps ) ; $ appName = $ questionHelper -> choose ( $ choices , 'Enter a number to choose an app:' ) ; } $ input -> setOption ( 'app' , $ appName ) ; return $ appName ; }
Find the name of the app the user wants to use for an SSH command.

@param InputInterface $input
The user input object.

@return string|null
The application name, or null if it could not be found.
Find the name of the app the user wants to use for an SSH command .