mirror of
https://github.com/getgrav/grav.git
synced 2025-10-26 07:56:07 +01:00
Added 'new' or 'new-project' command to combine Setup and Install
This commit is contained in:
1
bin/grav
1
bin/grav
@@ -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();
|
||||
|
||||
56
system/src/Grav/Console/NewCommand.php
Normal file
56
system/src/Grav/Console/NewCommand.php
Normal 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);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user