Liip\RMT\Command\InitCommand::execute PHP Method

execute() protected method

protected execute ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output )
$input Symfony\Component\Console\Input\InputInterface
$output Symfony\Component\Console\Output\OutputInterface
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        if ($this->informationCollector->getValueFor('configonly') == 'n') {
            // Create the executable task inside the project home
            $this->getOutput()->writeln("Creation of the new executable <info>{$this->executablePath}</info>");
            file_put_contents($this->executablePath, "#!/usr/bin/env php\n" . "<?php\n" . "define('RMT_ROOT_DIR', __DIR__);\n" . "require '{$this->commandPath}';\n");
            chmod('RMT', 0755);
        }
        // Create the config file from a template
        $this->getOutput()->writeln("Creation of the config file <info>{$this->configPath}</info>");
        $template = $this->informationCollector->getValueFor('vcs') == 'none' ? __DIR__ . '/../Config/templates/no-vcs-config.yml.tmpl' : __DIR__ . '/../Config/templates/default-vcs-config.yml.tmpl';
        $config = file_get_contents($template);
        $generator = $this->informationCollector->getValueFor('generator');
        foreach (array('generator' => $generator == 'semantic-versioning' ? 'semantic # More complex versionning (semantic)' : 'simple  # Same simple versionning', 'vcs' => $this->informationCollector->getValueFor('vcs'), 'persister' => $this->informationCollector->getValueFor('persister'), 'changelog-format' => $generator == 'semantic-versioning' ? 'semantic' : 'simple') as $key => $value) {
            $config = str_replace("%%{$key}%%", $value, $config);
        }
        file_put_contents($this->configPath, $config);
        // Confirmation
        $this->getOutput()->writeBigTitle('Success, you can start using RMT by calling "RMT release"');
        $this->getOutput()->writeEmptyLine();
    }