<commit_before><?php

namespace Dock\Cli;

use Dock\Cli\Helper\ContainerList;
use Dock\Cli\IO\ConsoleUserInteraction;
use Dock\Compose\Inspector;
use Dock\IO\SilentProcessRunner;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Process\Exception\ProcessFailedException;
use Symfony\Component\Process\Process;

class UpCommand extends Command
{
    /**
     * {@inheritdoc}
     */
    protected function configure()
    {
        $this
            ->setName('up')
            ->setDescription('Start the project')
        ;
    }

    /**
     * {@inheritdoc}
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $userInteraction = new ConsoleUserInteraction($input, $output);
        $processRunner = new SilentProcessRunner($userInteraction);

        if (!$this->inHomeDirectory()) {
            $output->writeln(
                '<error>The project have to be in your home directly to be able to share it with the Docker VM</error>'
            );

            return 1;
        }

        $userInteraction->writeTitle('Starting application containers');

        try {
            $processRunner->run(new Process('docker-compose up -d'));
            $userInteraction->writeTitle('Application containers successfully started');
        } catch (ProcessFailedException $e) {
            echo $e->getProcess()->getOutput();

            return 1;
        }

        // Display running containers
        $inspector = new Inspector($processRunner);
        $containers = $inspector->getRunningContainers();

        $list = new ContainerList($output);
        $list->render($containers);

        return 0;
    }

    /**
     * @return bool<commit_msg>Call `ps` command instead of using ContainerList helper<commit_after><?php

namespace Dock\Cli;

use Dock\Cli\IO\ConsoleUserInteraction;
use Dock\IO\SilentProcessRunner;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Process\Exception\ProcessFailedException;
use Symfony\Component\Process\Process;

class UpCommand extends Command
{
    /**
     * {@inheritdoc}
     */
    protected function configure()
    {
        $this
            ->setName('up')
            ->setDescription('Start the project')
        ;
    }

    /**
     * {@inheritdoc}
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $userInteraction = new ConsoleUserInteraction($input, $output);
        $processRunner = new SilentProcessRunner($userInteraction);

        if (!$this->inHomeDirectory()) {
            $output->writeln(
                '<error>The project have to be in your home directly to be able to share it with the Docker VM</error>'
            );

            return 1;
        }

        $userInteraction->writeTitle('Starting application containers');

        try {
            $processRunner->run(new Process('docker-compose up -d'));
            $userInteraction->writeTitle('Application containers successfully started');
        } catch (ProcessFailedException $e) {
            echo $e->getProcess()->getOutput();

            return 1;
        }

        return $this->getApplication()->run(
            new ArrayInput(['command' => 'ps']),
            $output
        );
    }

    /**
     * @return bool
{'fraction_non_alphanumeric': 0.11454239191465469, 'fraction_numerical': 0.001403705783267827, 'mean_word_length': 2.55234297108674, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 30, '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': '197617', 'n_tokens_mistral': 955, 'n_tokens_neox': 913, 'n_words': 210}