aboutsummaryrefslogtreecommitdiff
path: root/cli/Commands/Base/Tinker.php
blob: 1bc4f12773800a2e8e3dfed1465fc5fe59dc5a7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php

namespace Studip\Cli\Commands\Base;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Process\PhpExecutableFinder;
use Symfony\Component\Process\Process;
use Psy\Configuration;
use Psy\Shell;
use Psy\VersionUpdater\Checker;

class Tinker extends Command
{
    protected static $defaultName = 'tinker';

    protected function configure(): void
    {
        $this->setDescription('Interact with your Stud.IP in a read-eval-print loop (REPL).');
    }

    /**
     * @SuppressWarnings(PHPMD.StaticAccess)
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
     */
    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $config = Configuration::fromInput($input);
        $config->setUpdateCheck(Checker::NEVER);
        $config->setDefaultIncludes([__DIR__ . '/../../studip_cli_env.inc.php']);

        $shell = new Shell($config);

        return $shell->run();
    }
}