Closed LeonRyan closed 5 years ago
@LeonRyan cool and very helpful! Would you mind renaming it to InitCommand
and the CLI command to init
? I think that would align better with the git init
command that it essentially performs.
Also the class comment still says LogCommand
๐
Until it's merged, I'm copying the file manually into the Docker image. I have modified your command to look like this:
<?php namespace Grav\Plugin\Console;
use Grav\Console\ConsoleCommand;
use Grav\Plugin\GitSync\GitSync;
/**
* Class Initommand
*
* @package Grav\Plugin\Console
*/
class InitCommand extends ConsoleCommand
{
protected function configure()
{
$this
->setName('init')
->setDescription('Initializes your git repository')
->setHelp('The <info>init</info> command runs the same git commands as the onAdminAfterSave function. Use this to manually initialise git-sync (useful for automated deployments).')
;
}
protected function serve()
{
require_once __DIR__ . '/../vendor/autoload.php';
$plugin = new GitSync();
$repository = $plugin->getConfig('repository', false);
$this->output->writeln('');
if (!$repository) {
$this->output->writeln('<red>ERROR:</red> No repository has been configured');
}
$this->output->writeln('Initialising <cyan>' . $repository . '</cyan>');
$this->output->write('Starting Initialisation...');
$plugin->initializeRepository();
$plugin->setUser();
$plugin->addRemote();
$this->output->writeln('completed.');
}
}
Thanks guys. This looks good, agreed that init
is nicer.
Iโll review, apply @alex-mohemian changes and merge in the next coming days!
All changed and merged now. Thanks!
๐
Neat! ๐ That makes my Docker images even slimmer.
@w00fz I was a bit hasty when I fixed the class comment and I see you also did not notice the mistake.
This should obviously be InitCommand
. The spelling was also mixed British/American. I have fixed all of these in https://github.com/trilbymedia/grav-plugin-git-sync/pull/132
Oops! Thanks, I merged. Iโll probably wait next release cycle though as itโs relatively minor.
Added a CLI command to initialise git-sync. This is useful for automated deployments and Docker images where git-sync needs to be initialised before first run.
Should close issue #13 .