<commit_before><?php

namespace vierbergenlars\CliCentral\Command\Vhost;

use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use vierbergenlars\CliCentral\Configuration\VhostConfiguration;
use vierbergenlars\CliCentral\Helper\GlobalConfigurationHelper;

class ShowCommand extends AbstractMultiVhostsCommand
{
    protected function configure()
    {
        parent::configure();
        $this->setName('vhost:show')
        ;
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $configHelper = $this->getHelper('configuration');
        /* @var $configHelper GlobalConfigurationHelper */

        if(count($input->getArgument('vhosts')) == 1) {
            $vhostConfig = current($input->getArgument('vhosts'));
            /* @var $vhostConfig VhostConfiguration */
            $output->writeln(sprintf('Application: <info>%s</info>', $vhostConfig->getApplication()));
            $vhostLink = $vhostConfig->getLink();
            $vhostTarget = $vhostConfig->getTarget();
            $messages = [sprintf('Link: %s', $vhostConfig->getLink())];
            if(!$vhostLink->isLink())
                $messages[] = '<error>(Not a link)</error>';
            $output->writeln(implode(' ', $messages));
            if($vhostLink->isLink()&&$vhostLink->getLinkTarget() !== $vhostTarget->getPathname()) {
                    $output->writeln(sprintf('Target: <error>%s</error> (Should be <info>%s</info>)', $vhostLink->getLinkTarget(), $vhostTarget->getPathname()));
            } else {
                $output->writeln(sprintf('Target: %s', $vhostConfig->getOriginalTarget()));
            }
            $output->writeln(sprintf('Status: %s', $vhostConfig->getStatusMessage()));
        } else {
            $vhostConfigs = $input->getArgument('vhosts');
            $table = new Table($output);

            $table->setHeaders(['Vhost', 'Application', 'Status']);

            foreach($vhostConfigs as $vhost => $vhostConfig) {
                /* @var $vhostConfig VhostConfiguration */
                $table->addRow([
                    $vhost,
                    $vhostConfig->getApplication(),
                    $vhostConfig->getStatusMessage(),
                ]);
            }

            $table->render();
        }
    }
}
<commit_msg>Show vhosts table when using --all, even when there is only one vhost<commit_after><?php

namespace vierbergenlars\CliCentral\Command\Vhost;

use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use vierbergenlars\CliCentral\Configuration\VhostConfiguration;
use vierbergenlars\CliCentral\Helper\GlobalConfigurationHelper;

class ShowCommand extends AbstractMultiVhostsCommand
{
    protected function configure()
    {
        parent::configure();
        $this->setName('vhost:show')
        ;
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        if(count($input->getArgument('vhosts')) == 1&&!$input->getOption('all')) {
            $vhostConfig = current($input->getArgument('vhosts'));
            /* @var $vhostConfig VhostConfiguration */
            $output->writeln(sprintf('Application: <info>%s</info>', $vhostConfig->getApplication()));
            $vhostLink = $vhostConfig->getLink();
            $vhostTarget = $vhostConfig->getTarget();
            $messages = [sprintf('Link: %s', $vhostConfig->getLink())];
            if(!$vhostLink->isLink())
                $messages[] = '<error>(Not a link)</error>';
            $output->writeln(implode(' ', $messages));
            if($vhostLink->isLink()&&$vhostLink->getLinkTarget() !== $vhostTarget->getPathname()) {
                    $output->writeln(sprintf('Target: <error>%s</error> (Should be <info>%s</info>)', $vhostLink->getLinkTarget(), $vhostTarget->getPathname()));
            } else {
                $output->writeln(sprintf('Target: %s', $vhostConfig->getOriginalTarget()));
            }
            $output->writeln(sprintf('Status: %s', $vhostConfig->getStatusMessage()));
        } else {
            $vhostConfigs = $input->getArgument('vhosts');
            $table = new Table($output);

            $table->setHeaders(['Vhost', 'Application', 'Status']);

            foreach($vhostConfigs as $vhost => $vhostConfig) {
                /* @var $vhostConfig VhostConfiguration */
                $table->addRow([
                    $vhost,
                    $vhostConfig->getApplication(),
                    $vhostConfig->getStatusMessage(),
                ]);
            }

            $table->render();
        }
    }
}

{'fraction_non_alphanumeric': 0.15677609427609426, 'fraction_numerical': 0.00042087542087542086, 'mean_word_length': 2.6282442748091603, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 75, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3377736', 'n_tokens_mistral': 1322, 'n_tokens_neox': 1299, 'n_words': 197}