summaryrefslogtreecommitdiffstats
path: root/src/GitHubPagesDeploy/Console
diff options
context:
space:
mode:
Diffstat (limited to 'src/GitHubPagesDeploy/Console')
-rw-r--r--src/GitHubPagesDeploy/Console/Application.php24
-rw-r--r--src/GitHubPagesDeploy/Console/Command/DeployCommand.php33
2 files changed, 57 insertions, 0 deletions
diff --git a/src/GitHubPagesDeploy/Console/Application.php b/src/GitHubPagesDeploy/Console/Application.php
new file mode 100644
index 0000000..a7791ad
--- /dev/null
+++ b/src/GitHubPagesDeploy/Console/Application.php
@@ -0,0 +1,24 @@
+<?php
+
+namespace GitHubPagesDeploy\Console;
+
+use Symfony\Component\Console\Application as BaseApplication;
+use GitHubPagesDeploy\Console\Command\DeployCommand;
+
+class Application extends BaseApplication
+{
+ const NAME = 'GitHub Pages Deploy';
+ const VERSION = '@package_version@';
+
+ public function __construct()
+ {
+ parent::__construct(static::NAME, static::VERSION);
+ }
+
+ protected function getDefaultCommands()
+ {
+ $defaultCommands = parent::getDefaultCommands();
+ $defaultCommands[] = new DeployCommand();
+ return $defaultCommands;
+ }
+}
diff --git a/src/GitHubPagesDeploy/Console/Command/DeployCommand.php b/src/GitHubPagesDeploy/Console/Command/DeployCommand.php
new file mode 100644
index 0000000..70c7d8a
--- /dev/null
+++ b/src/GitHubPagesDeploy/Console/Command/DeployCommand.php
@@ -0,0 +1,33 @@
+<?php
+
+namespace GitHubPagesDeploy\Console\Command;
+
+use GitHubPagesDeploy\GitHubPagesDeploy;
+use Symfony\Component\Console\Command\Command;
+use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+
+class DeployCommand extends Command
+{
+ protected function configure()
+ {
+ $this
+ ->setName('deploy')
+ ->setDescription('Deploys the list of GitHub Pages repositories.')
+ ;
+ }
+
+ protected function execute(InputInterface $input, OutputInterface $output)
+ {
+ $deploy = GitHubPagesDeploy::fromFile();
+ $repositories = $deploy->getRepositories();
+ if (empty($repositories)) {
+ $output->writeln('<info>gh-pages-deploy.json is empty.</info>');
+ }
+ else {
+ $deploy->update();
+ }
+ }
+}