Skip to content

Commit

Permalink
Added command to open d.org issue page for current feature branch.
Browse files Browse the repository at this point in the history
  • Loading branch information
joachim-n committed Jun 24, 2024
1 parent 6e82d2c commit 3b7f929
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
49 changes: 49 additions & 0 deletions Command/OpenIssue.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

namespace Dorgflow\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Dorgflow\DependencyInjection\ContainerAwareTrait;
use Dorgflow\Service\Analyser;

/**
* Opens the d.org issue page for the current feature branch.
*
* Expects the system to have an `open` command which supports URLs.
*/
class OpenIssue extends Command {

use ContainerAwareTrait;

protected Analyser $analyser;

/**
* {@inheritdoc}
*/
protected function configure() {
$this
->setName('open')
->setDescription('Opens the issue for the current feature branch.')
->setHelp('Uses the system `open` command to open the issue for the current feature branch in the default browser.');
}

protected function setServices() {
$this->analyser = $this->container->get('analyser');
}

/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output): int {
$this->setServices();

$issue_number = $this->analyser->deduceIssueNumber();

exec('open https://www.drupal.org/node/' . $issue_number);

return 0;
}

}
1 change: 1 addition & 0 deletions dorgflow
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ $application->add($container->get('command.apply'));
$application->add($container->get('command.cleanup'));
$application->add($container->get('command.patch'));
$application->add($container->get('command.status'));
$application->add($container->get('command.open'));
$application->add($container->get('command.diff'));
$application->add($container->get('command.setup'));
$application->add($container->get('command.update'));
Expand Down
3 changes: 3 additions & 0 deletions services.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@
$container
->register('command.status', \Dorgflow\Command\Status::class)
->addMethodCall('setContainer', [new Reference('service_container')]);
$container
->register('command.open', \Dorgflow\Command\OpenIssue::class)
->addMethodCall('setContainer', [new Reference('service_container')]);
$container
->register('command.diff', \Dorgflow\Command\Diff::class)
->addMethodCall('setContainer', [new Reference('service_container')]);
Expand Down

0 comments on commit 3b7f929

Please sign in to comment.