Added 'new' or 'new-project' command to combine Setup and Install

This commit is contained in:
Djamil Legato
2014-08-12 13:06:54 -07:00
parent 2020e81a59
commit 858cb45421
2 changed files with 57 additions and 0 deletions

View File

@@ -18,5 +18,6 @@ $app->addCommands(array(
new Grav\Console\InstallCommand(),
new Grav\Console\SetupCommand(),
new Grav\Console\CleanCommand(),
new Grav\Console\NewCommand(),
));
$app->run();

View File

@@ -0,0 +1,56 @@
<?php
namespace Grav\Console;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\ArrayInput;
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\Formatter\OutputFormatterStyle;
use \Symfony\Component\Yaml\Yaml;
class NewCommand extends Command {
protected function configure() {
$this
->setName("new")
->setAliases(array('new-project'))
->addArgument(
'destination',
InputArgument::REQUIRED,
'The destination directory of your new Grav project'
)
->addOption(
'symlink',
's',
InputOption::VALUE_NONE,
'Symlink the required bits'
)
->setDescription("Handles setting up a new Instance of Grav")
->setHelp('The <info>new</info> command provides clone and symlink installation chores');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$setupCommand = $this->getApplication()->find('setup');
$installCommand = $this->getApplication()->find('install');
$setupArguments = new ArrayInput(array(
'command' => 'setup',
'destination' => $input->getArgument('destination'),
'-s' => $input->getOption('symlink')
));
$installArguments = new ArrayInput(array(
'command' => 'install',
'destination' => $input->getArgument('destination'),
'-s' => $input->getOption('symlink')
));
$setupCommand->run($setupArguments, $output);
$installCommand->run($installArguments, $output);
}
}