diff --git a/system/src/Grav/Console/Cli/BackupCommand.php b/system/src/Grav/Console/Cli/BackupCommand.php
index a597efc7d..d8b8500fb 100644
--- a/system/src/Grav/Console/Cli/BackupCommand.php
+++ b/system/src/Grav/Console/Cli/BackupCommand.php
@@ -2,23 +2,17 @@
namespace Grav\Console\Cli;
use Grav\Common\Backup\ZipBackup;
-use Grav\Console\ConsoleTrait;
+use Grav\Console\ConsoleCommand;
use RocketTheme\Toolbox\File\JsonFile;
-use Symfony\Component\Console\Command\Command;
-use Symfony\Component\Console\Formatter\OutputFormatterStyle;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\InputArgument;
-use Symfony\Component\Console\Input\InputInterface;
-use Symfony\Component\Console\Output\OutputInterface;
/**
* Class BackupCommand
* @package Grav\Console\Cli
*/
-class BackupCommand extends Command
+class BackupCommand extends ConsoleCommand
{
- use ConsoleTrait;
-
protected $source;
protected $progress;
@@ -42,21 +36,16 @@ class BackupCommand extends Command
}
/**
- * @param InputInterface $input
- * @param OutputInterface $output
- *
* @return int|null|void
*/
- protected function execute(InputInterface $input, OutputInterface $output)
+ protected function serve()
{
- $this->setupConsole($input, $output);
-
- $this->progress = new ProgressBar($output);
+ $this->progress = new ProgressBar($this->output);
$this->progress->setFormat('Archiving %current% files [%bar%] %elapsed:6s% %memory:6s%');
self::getGrav()['config']->init();
- $destination = ($input->getArgument('destination')) ? $input->getArgument('destination') : null;
+ $destination = ($this->input->getArgument('destination')) ? $this->input->getArgument('destination') : null;
$log = JsonFile::instance(self::getGrav()['locator']->findResource("log://backup.log", true, true));
$backup = ZipBackup::backup($destination, [$this, 'output']);
@@ -66,16 +55,13 @@ class BackupCommand extends Command
]);
$log->save();
- $output->writeln('');
- $output->writeln('');
+ $this->output->writeln('');
+ $this->output->writeln('');
}
/**
- * @param $folder
- * @param $zipFile
- * @param $exclusiveLength
- * @param $progress
+ * @param $args
*/
public function output($args)
{
diff --git a/system/src/Grav/Console/Cli/CleanCommand.php b/system/src/Grav/Console/Cli/CleanCommand.php
index 350c9ab54..4b9544c4c 100644
--- a/system/src/Grav/Console/Cli/CleanCommand.php
+++ b/system/src/Grav/Console/Cli/CleanCommand.php
@@ -2,20 +2,14 @@
namespace Grav\Console\Cli;
use Grav\Common\Filesystem\Folder;
-use Grav\Console\ConsoleTrait;
-use Symfony\Component\Console\Command\Command;
-use Symfony\Component\Console\Formatter\OutputFormatterStyle;
-use Symfony\Component\Console\Input\InputInterface;
-use Symfony\Component\Console\Output\OutputInterface;
+use Grav\Console\ConsoleCommand;
/**
* Class CleanCommand
* @package Grav\Console\Cli
*/
-class CleanCommand extends Command
+class CleanCommand extends ConsoleCommand
{
- use ConsoleTrait;
-
/**
* @var array
*/
@@ -172,14 +166,10 @@ class CleanCommand extends Command
}
/**
- * @param InputInterface $input
- * @param OutputInterface $output
- *
* @return int|null|void
*/
- protected function execute(InputInterface $input, OutputInterface $output)
+ protected function serve()
{
- $this->setupConsole($input, $output);
$this->cleanPaths();
}
diff --git a/system/src/Grav/Console/Cli/ClearCacheCommand.php b/system/src/Grav/Console/Cli/ClearCacheCommand.php
index 944064839..a675a66f2 100644
--- a/system/src/Grav/Console/Cli/ClearCacheCommand.php
+++ b/system/src/Grav/Console/Cli/ClearCacheCommand.php
@@ -2,29 +2,24 @@
namespace Grav\Console\Cli;
use Grav\Common\Cache;
-use Grav\Console\ConsoleTrait;
-use Symfony\Component\Console\Command\Command;
-use Symfony\Component\Console\Formatter\OutputFormatterStyle;
-use Symfony\Component\Console\Input\InputInterface;
+use Grav\Console\ConsoleCommand;
use Symfony\Component\Console\Input\InputOption;
-use Symfony\Component\Console\Output\OutputInterface;
/**
* Class ClearCacheCommand
* @package Grav\Console\Cli
*/
-class ClearCacheCommand extends Command
+class ClearCacheCommand extends ConsoleCommand
{
- use ConsoleTrait;
-
/**
*
*/
protected function configure()
{
$this
- ->setName("clear-cache")
- ->setDescription("Clears Grav cache")
+ ->setName('clear-cache')
+ ->setAliases(['clearcache'])
+ ->setDescription('Clears Grav cache')
->addOption('all', null, InputOption::VALUE_NONE, 'If set will remove all including compiled, twig, doctrine caches')
->addOption('assets-only', null, InputOption::VALUE_NONE, 'If set will remove only assets/*')
->addOption('images-only', null, InputOption::VALUE_NONE, 'If set will remove only images/*')
@@ -33,14 +28,10 @@ class ClearCacheCommand extends Command
}
/**
- * @param InputInterface $input
- * @param OutputInterface $output
- *
* @return int|null|void
*/
- protected function execute(InputInterface $input, OutputInterface $output)
+ protected function serve()
{
- $this->setupConsole($input, $output);
$this->cleanPaths();
}
diff --git a/system/src/Grav/Console/Cli/ComposerCommand.php b/system/src/Grav/Console/Cli/ComposerCommand.php
index 843df5c76..729b425a8 100644
--- a/system/src/Grav/Console/Cli/ComposerCommand.php
+++ b/system/src/Grav/Console/Cli/ComposerCommand.php
@@ -1,23 +1,16 @@
setupConsole($input, $output);
+ $action = $this->input->getOption('install') ? 'install' : ($this->input->getOption('update') ? 'update' : 'install');
- $action = $input->getOption('install') ? 'install' : ($input->getOption('update') ? 'update' : 'install');
-
- if ($input->getOption('install')) {
+ if ($this->input->getOption('install')) {
$action = 'install';
}
// Updates composer first
- $output->writeln("\nInstalling vendor dependencies");
- $output->writeln($this->composerUpdate(GRAV_ROOT, $action));
+ $this->output->writeln("\nInstalling vendor dependencies");
+ $this->output->writeln($this->composerUpdate(GRAV_ROOT, $action));
}
}
diff --git a/system/src/Grav/Console/Cli/InstallCommand.php b/system/src/Grav/Console/Cli/InstallCommand.php
index 6a5c84f68..8b6e36eb9 100644
--- a/system/src/Grav/Console/Cli/InstallCommand.php
+++ b/system/src/Grav/Console/Cli/InstallCommand.php
@@ -1,22 +1,17 @@
setupConsole($input, $output);
-
$dependencies_file = '.dependencies';
- $this->destination = ($input->getArgument('destination')) ? $input->getArgument('destination') : ROOT_DIR;
+ $this->destination = ($this->input->getArgument('destination')) ? $this->input->getArgument('destination') : ROOT_DIR;
// fix trailing slash
$this->destination = rtrim($this->destination, DS) . DS;
@@ -78,7 +68,7 @@ class InstallCommand extends Command
$local_config_file = exec('eval echo ~/.grav/config');
if (file_exists($local_config_file)) {
$this->local_config = Yaml::parse($local_config_file);
- $output->writeln('Read local config from ' . $local_config_file . '');
+ $this->output->writeln('Read local config from ' . $local_config_file . '');
}
}
@@ -88,22 +78,22 @@ class InstallCommand extends Command
} elseif (file_exists($this->destination . $dependencies_file)) {
$this->config = Yaml::parse($this->destination . $dependencies_file);
} else {
- $output->writeln('ERROR Missing .dependencies file in user/ folder');
+ $this->output->writeln('ERROR Missing .dependencies file in user/ folder');
}
// If yaml config, process
if ($this->config) {
- if (!$input->getOption('symlink')) {
+ if (!$this->input->getOption('symlink')) {
// Updates composer first
- $output->writeln("\nInstalling vendor dependencies");
- $output->writeln($this->composerUpdate(GRAV_ROOT, 'install'));
+ $this->output->writeln("\nInstalling vendor dependencies");
+ $this->output->writeln($this->composerUpdate(GRAV_ROOT, 'install'));
$this->gitclone();
} else {
$this->symlink();
}
} else {
- $output->writeln('ERROR invalid YAML in ' . $dependencies_file);
+ $this->output->writeln('ERROR invalid YAML in ' . $dependencies_file);
}
diff --git a/system/src/Grav/Console/Cli/NewProjectCommand.php b/system/src/Grav/Console/Cli/NewProjectCommand.php
index 6e193fe25..2d63f04dd 100644
--- a/system/src/Grav/Console/Cli/NewProjectCommand.php
+++ b/system/src/Grav/Console/Cli/NewProjectCommand.php
@@ -1,29 +1,25 @@
setName("new-project")
+ ->setName('new-project')
+ ->setAliases(['newproject'])
->addArgument(
'destination',
InputArgument::REQUIRED,
@@ -35,37 +31,32 @@ class NewProjectCommand extends Command
InputOption::VALUE_NONE,
'Symlink the required bits'
)
- ->setDescription("Creates a new Grav project with all the dependencies installed")
- ->setHelp("The new-project command is a combination of the `setup` and `install` commands.\nCreates a new Grav instance and performs the installation of all the required dependencies.");
+ ->setDescription('Creates a new Grav project with all the dependencies installed')
+ ->setHelp('The new-project command is a combination of the `setup` and `install` commands.\nCreates a new Grav instance and performs the installation of all the required dependencies.');
}
/**
- * @param InputInterface $input
- * @param OutputInterface $output
- *
* @return int|null|void
*/
- protected function execute(InputInterface $input, OutputInterface $output)
+ protected function serve()
{
- $this->setupConsole($input, $output);
-
$sandboxCommand = $this->getApplication()->find('sandbox');
$installCommand = $this->getApplication()->find('install');
$sandboxArguments = new ArrayInput(array(
'command' => 'sandbox',
- 'destination' => $input->getArgument('destination'),
- '-s' => $input->getOption('symlink')
+ 'destination' => $this->input->getArgument('destination'),
+ '-s' => $this->input->getOption('symlink')
));
$installArguments = new ArrayInput(array(
'command' => 'install',
- 'destination' => $input->getArgument('destination'),
- '-s' => $input->getOption('symlink')
+ 'destination' => $this->input->getArgument('destination'),
+ '-s' => $this->input->getOption('symlink')
));
- $sandboxCommand->run($sandboxArguments, $output);
- $installCommand->run($installArguments, $output);
+ $sandboxCommand->run($sandboxArguments, $this->output);
+ $installCommand->run($installArguments, $this->output);
}
}
diff --git a/system/src/Grav/Console/Cli/NewUserCommand.php b/system/src/Grav/Console/Cli/NewUserCommand.php
index fde277adf..0dba9c670 100644
--- a/system/src/Grav/Console/Cli/NewUserCommand.php
+++ b/system/src/Grav/Console/Cli/NewUserCommand.php
@@ -1,48 +1,40 @@
setName("newuser")
- ->setDescription("Creates a new user")
- ->setHelp('The newuser creates a new user file in user/accounts/ folder');
+ ->setName('new-user')
+ ->setAliases(['newuser'])
+ ->setDescription('Creates a new user')
+ ->setHelp('The newuser creates a new user file in user/accounts/ folder')
+ ;
}
/**
- * @param InputInterface $input
- * @param OutputInterface $output
- *
* @return int|null|void
*/
- protected function execute(InputInterface $input, OutputInterface $output)
+ protected function serve()
{
- $this->setupConsole($input, $output);
$helper = $this->getHelper('question');
- $data = [];
+ $data = [];
$this->output->writeln('Create new user');
$this->output->writeln('');
@@ -51,13 +43,13 @@ class NewUserCommand extends Command
$question = new Question('Enter a username: ', 'admin');
$question->setValidator(function ($value) {
if (!preg_match('/^[a-z0-9_-]{3,16}$/', $value)) {
- throw new RuntimeException(
+ throw new \RuntimeException(
'Username should be between 3 and 16 characters, including lowercase letters, numbers, underscores, and hyphens. Uppercase letters, spaces, and special characters are not allowed'
);
}
if (file_exists(self::getGrav()['locator']->findResource('user://accounts/' . $value . YAML_EXT))) {
- throw new RuntimeException(
- 'Username "'.$value.'" already exists, please pick another username'
+ throw new \RuntimeException(
+ 'Username "' . $value . '" already exists, please pick another username'
);
}
return $value;
@@ -65,14 +57,14 @@ class NewUserCommand extends Command
$username = $helper->ask($this->input, $this->output, $question);
// Get password and validate
- $password = $this->askForPassword($helper, 'Enter a password: ', function ($password1) use ($helper) {
+ $password = $this->askForPassword($helper, 'Enter a password: ', function ($password1) use ($helper) {
if (!preg_match('/(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}/', $password1)) {
- throw new RuntimeException('Password must contain at least one number and one uppercase and lowercase letter, and at least 8 or more characters');
+ throw new \RuntimeException('Password must contain at least one number and one uppercase and lowercase letter, and at least 8 or more characters');
}
// Since input is hidden when prompting for passwords, the user is asked to repeat the password
return $this->askForPassword($helper, 'Repeat the password: ', function ($password2) use ($password1) {
if (strcmp($password2, $password1)) {
- throw new RuntimeException('Passwords did not match.');
+ throw new \RuntimeException('Passwords did not match.');
}
return $password2;
});
@@ -83,7 +75,7 @@ class NewUserCommand extends Command
$question = new Question('Enter an email: ');
$question->setValidator(function ($value) {
if (!preg_match('/^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/', $value)) {
- throw new RuntimeException(
+ throw new \RuntimeException(
'Not a valid email address'
);
}
@@ -94,7 +86,7 @@ class NewUserCommand extends Command
// Choose permissions
$question = new ChoiceQuestion(
'Please choose a set of permissions:',
- array('a'=>'admin access', 's'=>'site access', 'b'=>'admin and site access'),
+ array('a' => 'admin access', 's' => 'site access', 'b' => 'admin and site access'),
'a'
);
$question->setErrorMessage('permissions %s is invalid.');
@@ -109,14 +101,14 @@ class NewUserCommand extends Command
break;
case 'b':
$data['access']['admin'] = ['login' => true, 'super' => true];
- $data['access']['site'] = ['login' => true];
+ $data['access']['site'] = ['login' => true];
}
// Get fullname
$question = new Question('Enter a fullname: ');
$question->setValidator(function ($value) {
if ($value === null || trim($value) == '') {
- throw new RuntimeException(
+ throw new \RuntimeException(
'Fullname is required'
);
}
@@ -125,7 +117,7 @@ class NewUserCommand extends Command
$data['fullname'] = $helper->ask($this->input, $this->output, $question);
// Get title
- $question = new Question('Enter a title: ');
+ $question = new Question('Enter a title: ');
$data['title'] = $helper->ask($this->input, $this->output, $question);
// Create user object and save it
@@ -135,15 +127,15 @@ class NewUserCommand extends Command
$user->save();
$this->output->writeln('');
- $this->output->writeln('Success! User '. $username .' created.');
+ $this->output->writeln('Success! User ' . $username . ' created.');
}
/**
* Get password and validate.
*
- * @param Helper $helper
- * @param string $question
- * @param callable $validator
+ * @param Helper $helper
+ * @param string $question
+ * @param callable $validator
*
* @return string
*/
diff --git a/system/src/Grav/Console/Cli/SandboxCommand.php b/system/src/Grav/Console/Cli/SandboxCommand.php
index d490655a6..a77bc9720 100644
--- a/system/src/Grav/Console/Cli/SandboxCommand.php
+++ b/system/src/Grav/Console/Cli/SandboxCommand.php
@@ -1,23 +1,17 @@
setupConsole($input, $output);
- $this->destination = $input->getArgument('destination');
+ $this->destination = $this->input->getArgument('destination');
// Symlink the Core Stuff
- if ($input->getOption('symlink')) {
+ if ($this->input->getOption('symlink')) {
// Create Some core stuff if it doesn't exist
$this->createDirectories();
diff --git a/system/src/Grav/Console/ConsoleCommand.php b/system/src/Grav/Console/ConsoleCommand.php
new file mode 100644
index 000000000..0a0ffe648
--- /dev/null
+++ b/system/src/Grav/Console/ConsoleCommand.php
@@ -0,0 +1,35 @@
+setupConsole($input, $output);
+ $this->serve();
+ }
+
+ /**
+ *
+ */
+ protected function serve() { }
+
+}
\ No newline at end of file
diff --git a/system/src/Grav/Console/Gpm/IndexCommand.php b/system/src/Grav/Console/Gpm/IndexCommand.php
index f5b3e1618..b75c55d59 100644
--- a/system/src/Grav/Console/Gpm/IndexCommand.php
+++ b/system/src/Grav/Console/Gpm/IndexCommand.php
@@ -2,20 +2,16 @@
namespace Grav\Console\Gpm;
use Grav\Common\GPM\GPM;
-use Grav\Console\ConsoleTrait;
-use Symfony\Component\Console\Command\Command;
-use Symfony\Component\Console\Input\InputInterface;
+use Grav\Console\ConsoleCommand;
use Symfony\Component\Console\Input\InputOption;
-use Symfony\Component\Console\Output\OutputInterface;
/**
* Class IndexCommand
+ *
* @package Grav\Console\Gpm
*/
-class IndexCommand extends Command
+class IndexCommand extends ConsoleCommand
{
- use ConsoleTrait;
-
/**
* @var
*/
@@ -39,19 +35,15 @@ class IndexCommand extends Command
'Force re-fetching the data from remote'
)
->setDescription("Lists the plugins and themes available for installation")
- ->setHelp('The index command lists the plugins and themes available for installation');
+ ->setHelp('The index command lists the plugins and themes available for installation')
+ ;
}
/**
- * @param InputInterface $input
- * @param OutputInterface $output
- *
* @return int|null|void
*/
- protected function execute(InputInterface $input, OutputInterface $output)
+ protected function serve()
{
- $this->setupConsole($input, $output);
-
$this->gpm = new GPM($this->input->getOption('force'));
$this->data = $this->gpm->getRepository();
@@ -93,15 +85,15 @@ class IndexCommand extends Command
*/
private function versionDetails($package)
{
- $list = $this->gpm->{'getUpdatable' . ucfirst($package->package_type)}();
- $package = isset($list[$package->slug]) ? $list[$package->slug] : $package;
- $type = ucfirst(preg_replace("/s$/", '', $package->package_type));
+ $list = $this->gpm->{'getUpdatable' . ucfirst($package->package_type)}();
+ $package = isset($list[$package->slug]) ? $list[$package->slug] : $package;
+ $type = ucfirst(preg_replace("/s$/", '', $package->package_type));
$updatable = $this->gpm->{'is' . $type . 'Updatable'}($package->slug);
$installed = $this->gpm->{'is' . $type . 'Installed'}($package->slug);
- $local = $this->gpm->{'getInstalled' . $type}($package->slug);
+ $local = $this->gpm->{'getInstalled' . $type}($package->slug);
if (!$installed || !$updatable) {
- $version = $installed ? $local->version : $package->version;
+ $version = $installed ? $local->version : $package->version;
$installed = !$installed ? ' (not installed)' : ' (installed)';
return str_pad(" [v" . $version . "]", 35) . $installed;
diff --git a/system/src/Grav/Console/Gpm/InfoCommand.php b/system/src/Grav/Console/Gpm/InfoCommand.php
index 53290b8ec..0ff0850bb 100644
--- a/system/src/Grav/Console/Gpm/InfoCommand.php
+++ b/system/src/Grav/Console/Gpm/InfoCommand.php
@@ -2,21 +2,16 @@
namespace Grav\Console\Gpm;
use Grav\Common\GPM\GPM;
-use Grav\Console\ConsoleTrait;
-use Symfony\Component\Console\Command\Command;
+use Grav\Console\ConsoleCommand;
use Symfony\Component\Console\Input\InputArgument;
-use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
-use Symfony\Component\Console\Output\OutputInterface;
/**
* Class InfoCommand
* @package Grav\Console\Gpm
*/
-class InfoCommand extends Command
+class InfoCommand extends ConsoleCommand
{
- use ConsoleTrait;
-
/**
* @var
*/
@@ -49,20 +44,16 @@ class InfoCommand extends Command
}
/**
- * @param InputInterface $input
- * @param OutputInterface $output
- *
* @return int|null|void
*/
- protected function execute(InputInterface $input, OutputInterface $output)
+ protected function serve()
{
- $this->setupConsole($input, $output);
$this->gpm = new GPM($this->input->getOption('force'));
- $foundPackage = $this->gpm->findPackage($input->getArgument('package'));
+ $foundPackage = $this->gpm->findPackage($this->input->getArgument('package'));
if (!$foundPackage) {
- $this->output->writeln("The package '" . $input->getArgument('package') . "' was not found in the Grav repository.");
+ $this->output->writeln("The package '" . $this->input->getArgument('package') . "' was not found in the Grav repository.");
$this->output->writeln('');
$this->output->writeln("You can list all the available packages by typing:");
$this->output->writeln(" " . $this->argv . " index");
@@ -70,7 +61,7 @@ class InfoCommand extends Command
exit;
}
- $this->output->writeln("Found package '" . $input->getArgument('package') . "' under the '" . ucfirst($foundPackage->package_type) . "' section");
+ $this->output->writeln("Found package '" . $this->input->getArgument('package') . "' under the '" . ucfirst($foundPackage->package_type) . "' section");
$this->output->writeln('');
$this->output->writeln("" . $foundPackage->name . " [" . $foundPackage->slug . "]");
$this->output->writeln(str_repeat('-', strlen($foundPackage->name) + strlen($foundPackage->slug) + 3));
diff --git a/system/src/Grav/Console/Gpm/InstallCommand.php b/system/src/Grav/Console/Gpm/InstallCommand.php
index 40bb68015..dca4fe77b 100644
--- a/system/src/Grav/Console/Gpm/InstallCommand.php
+++ b/system/src/Grav/Console/Gpm/InstallCommand.php
@@ -5,14 +5,10 @@ use Grav\Common\Filesystem\Folder;
use Grav\Common\GPM\GPM;
use Grav\Common\GPM\Installer;
use Grav\Common\GPM\Response;
-use Grav\Common\Inflector;
use Grav\Common\Utils;
-use Grav\Console\ConsoleTrait;
-use Symfony\Component\Console\Command\Command;
+use Grav\Console\ConsoleCommand;
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\Question\ConfirmationQuestion;
use Symfony\Component\Console\Question\ChoiceQuestion;
use Symfony\Component\Yaml\Yaml;
@@ -23,10 +19,8 @@ define('GIT_REGEX', '/http[s]?:\/\/(?:.*@)?(github|bitbucket)(?:.org|.com)\/.*\/
* Class InstallCommand
* @package Grav\Console\Gpm
*/
-class InstallCommand extends Command
+class InstallCommand extends ConsoleCommand
{
- use ConsoleTrait;
-
/**
* @var
*/
@@ -87,15 +81,10 @@ class InstallCommand extends Command
}
/**
- * @param InputInterface $input
- * @param OutputInterface $output
- *
* @return int|null|void
*/
- protected function execute(InputInterface $input, OutputInterface $output)
+ protected function serve()
{
- $this->setupConsole($input, $output);
-
$this->gpm = new GPM($this->input->getOption('force'));
$this->destination = realpath($this->input->getOption('destination'));
diff --git a/system/src/Grav/Console/Gpm/SelfupgradeCommand.php b/system/src/Grav/Console/Gpm/SelfupgradeCommand.php
index 9647470f1..d2ef2d2d6 100644
--- a/system/src/Grav/Console/Gpm/SelfupgradeCommand.php
+++ b/system/src/Grav/Console/Gpm/SelfupgradeCommand.php
@@ -5,22 +5,17 @@ use Grav\Common\Filesystem\Folder;
use Grav\Common\GPM\Installer;
use Grav\Common\GPM\Response;
use Grav\Common\GPM\Upgrader;
-use Grav\Console\ConsoleTrait;
+use Grav\Console\ConsoleCommand;
use Symfony\Component\Console\Input\ArrayInput;
-use Symfony\Component\Console\Command\Command;
-use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
-use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\ConfirmationQuestion;
/**
* Class SelfupgradeCommand
* @package Grav\Console\Gpm
*/
-class SelfupgradeCommand extends Command
+class SelfupgradeCommand extends ConsoleCommand
{
- use ConsoleTrait;
-
/**
* @var
*/
@@ -75,14 +70,10 @@ class SelfupgradeCommand extends Command
}
/**
- * @param InputInterface $input
- * @param OutputInterface $output
- *
* @return int|null|void
*/
- protected function execute(InputInterface $input, OutputInterface $output)
+ protected function serve()
{
- $this->setupConsole($input, $output);
$this->upgrader = new Upgrader($this->input->getOption('force'));
$update = $this->upgrader->getAssets()['grav-update'];
diff --git a/system/src/Grav/Console/Gpm/UninstallCommand.php b/system/src/Grav/Console/Gpm/UninstallCommand.php
index b30fd4948..dfe37e9ed 100644
--- a/system/src/Grav/Console/Gpm/UninstallCommand.php
+++ b/system/src/Grav/Console/Gpm/UninstallCommand.php
@@ -3,22 +3,17 @@ namespace Grav\Console\Gpm;
use Grav\Common\GPM\GPM;
use Grav\Common\GPM\Installer;
-use Grav\Console\ConsoleTrait;
-use Symfony\Component\Console\Command\Command;
+use Grav\Console\ConsoleCommand;
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\Question\ConfirmationQuestion;
/**
* Class UninstallCommand
* @package Grav\Console\Gpm
*/
-class UninstallCommand extends Command
+class UninstallCommand extends ConsoleCommand
{
- use ConsoleTrait;
-
/**
* @var
*/
@@ -63,15 +58,10 @@ class UninstallCommand extends Command
}
/**
- * @param InputInterface $input
- * @param OutputInterface $output
- *
* @return int|null|void
*/
- protected function execute(InputInterface $input, OutputInterface $output)
+ protected function serve()
{
- $this->setupConsole($input, $output);
-
$this->gpm = new GPM();
$packages = array_map('strtolower', $this->input->getArgument('package'));
diff --git a/system/src/Grav/Console/Gpm/UpdateCommand.php b/system/src/Grav/Console/Gpm/UpdateCommand.php
index f5c3f9a1d..5ca795ea8 100644
--- a/system/src/Grav/Console/Gpm/UpdateCommand.php
+++ b/system/src/Grav/Console/Gpm/UpdateCommand.php
@@ -3,23 +3,18 @@ namespace Grav\Console\Gpm;
use Grav\Common\GPM\GPM;
use Grav\Common\GPM\Installer;
-use Grav\Console\ConsoleTrait;
-use Symfony\Component\Console\Command\Command;
+use Grav\Console\ConsoleCommand;
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\Question\ConfirmationQuestion;
/**
* Class UpdateCommand
* @package Grav\Console\Gpm
*/
-class UpdateCommand extends Command
+class UpdateCommand extends ConsoleCommand
{
- use ConsoleTrait;
-
/**
* @var
*/
@@ -85,15 +80,10 @@ class UpdateCommand extends Command
}
/**
- * @param InputInterface $input
- * @param OutputInterface $output
- *
* @return int|null|void
*/
- protected function execute(InputInterface $input, OutputInterface $output)
+ protected function serve()
{
- $this->setupConsole($input, $output);
-
$this->gpm = new GPM($this->input->getOption('force'));
$this->destination = realpath($this->input->getOption('destination'));
$skip_prompt = $this->input->getOption('all-yes');
diff --git a/system/src/Grav/Console/Gpm/VersionCommand.php b/system/src/Grav/Console/Gpm/VersionCommand.php
index c1068d8ab..231645dcc 100644
--- a/system/src/Grav/Console/Gpm/VersionCommand.php
+++ b/system/src/Grav/Console/Gpm/VersionCommand.php
@@ -3,21 +3,16 @@ namespace Grav\Console\Gpm;
use Grav\Common\GPM\GPM;
use Grav\Common\GPM\Upgrader;
-use Grav\Console\ConsoleTrait;
-use Symfony\Component\Console\Command\Command;
+use Grav\Console\ConsoleCommand;
use Symfony\Component\Console\Input\InputArgument;
-use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
-use Symfony\Component\Console\Output\OutputInterface;
/**
* Class VersionCommand
* @package Grav\Console\Gpm
*/
-class VersionCommand extends Command
+class VersionCommand extends ConsoleCommand
{
- use ConsoleTrait;
-
/**
* @var
*/
@@ -46,15 +41,10 @@ class VersionCommand extends Command
}
/**
- * @param InputInterface $input
- * @param OutputInterface $output
- *
* @return int|null|void
*/
- protected function execute(InputInterface $input, OutputInterface $output)
+ protected function serve()
{
- $this->setupConsole($input, $output);
-
$this->gpm = new GPM($this->input->getOption('force'));
$packages = $this->input->getArgument('package');