Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,15 @@ The `github-pr-comments` CLI command fetches merged pull request comments from a

4. **Run** the command:

**Important:** You must include the command name `github-pr-comments` when using CLI options.

```bash
# Using environment variables from .env file
php cli/github-pr-comments.php github-pr-comments
php cli/github-pr-comments.php

# With date filter
php cli/github-pr-comments.php github-pr-comments --merged-since=2025-11-05
php cli/github-pr-comments.php --merged-since=2025-11-05

# With all CLI options
php cli/github-pr-comments.php github-pr-comments \
php cli/github-pr-comments.php \
--token=your_token_here \
--owner=your_org \
--repo=your_repo \
Expand All @@ -82,18 +80,18 @@ The `github-pr-comments` CLI command fetches merged pull request comments from a

```bash
# Filter PRs merged since a specific date
php cli/github-pr-comments.php github-pr-comments --merged-since=2025-11-05
php cli/github-pr-comments.php --merged-since=2025-11-05

# Override milestone and keywords from CLI
php cli/github-pr-comments.php github-pr-comments \
php cli/github-pr-comments.php \
--milestone="v1.0.0" \
--keyword="tested" \
--keyword="LGTM"
```

Get a list of all possible options:
```bash
php cli/github-pr-comments.php github-pr-comments --help
php cli/github-pr-comments.php --help
```

**Result**
Expand Down
45 changes: 21 additions & 24 deletions cli/github-pr-comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

require __DIR__ . '/../vendor/autoload.php';

use Joomla\Console\Application;
use Joomla\Console\Command\AbstractCommand;
use Joomla\Http\HttpFactory;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
Expand All @@ -15,28 +15,23 @@
$dotenv->load(__DIR__ . '/../.env');


class GithubCommentsCli extends AbstractCommand
class GithubCommentsCli extends Command
{
protected static $defaultName = 'github-pr-comments';
protected static $defaultDescription = 'Fetch merged PR comments by milestone + filter by phrase';

public function __construct()
protected function configure(): void
{
parent::__construct();
$this->getDefinition()->addOption(new InputOption('token', null, InputOption::VALUE_OPTIONAL, 'GitHub token'));
$this->getDefinition()->addOption(new InputOption('owner', null, InputOption::VALUE_OPTIONAL, 'GitHub owner'));
$this->getDefinition()->addOption(new InputOption('repo', null, InputOption::VALUE_OPTIONAL, 'GitHub repository'));
$this->getDefinition()->addOption(new InputOption('base', null, InputOption::VALUE_OPTIONAL, 'PR base branch'));
$this->getDefinition()->addOption(new InputOption('milestone', null, InputOption::VALUE_OPTIONAL, 'PR milestone'));
// Accept multiple --keyword entries
$this->getDefinition()->addOption(
new InputOption('keyword', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Filter keyword(s)')
);
// Date filter for merged PRs (optional)
$this->getDefinition()->addOption(new InputOption('merged-since', null, InputOption::VALUE_OPTIONAL, 'Date filter for merged PRs (YYYY-MM-DD)'));
$this
->setName('github-pr-comments')
->setDescription('Fetch merged PR comments by milestone + filter by phrase')
->addOption('token', null, InputOption::VALUE_OPTIONAL, 'GitHub token')
->addOption('owner', null, InputOption::VALUE_OPTIONAL, 'GitHub owner')
->addOption('repo', null, InputOption::VALUE_OPTIONAL, 'GitHub repository')
->addOption('base', null, InputOption::VALUE_OPTIONAL, 'PR base branch')
->addOption('milestone', null, InputOption::VALUE_OPTIONAL, 'PR milestone')
->addOption('keyword', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Filter keyword(s)')
->addOption('merged-since', null, InputOption::VALUE_OPTIONAL, 'Date filter for merged PRs (YYYY-MM-DD)');
}

protected function doExecute(InputInterface $input, OutputInterface $output): int
protected function execute(InputInterface $input, OutputInterface $output): int
{
$token = $input->getOption('token') ?? $_ENV['GITHUB_TOKEN'] ?? null;
$owner = $input->getOption('owner') ?? $_ENV['GITHUB_OWNER'] ?? null;
Expand Down Expand Up @@ -235,7 +230,9 @@ protected function doExecute(InputInterface $input, OutputInterface $output): in
}
}

// Bootstrap Joomla Console application
$app = new Application();
$app->addCommand(new GithubCommentsCli());
$app->execute();
// Bootstrap Symfony Console application
$command = new GithubCommentsCli();
$app = new Application('GitHub PR Comments', '1.0.0');
$app->addCommand($command);
$app->setDefaultCommand('github-pr-comments', true);
$app->run();
7 changes: 2 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
{
"name": "martina/github-comment",
"description": "Joomla CLI script to fetch merged PR comments via GitHub GraphQL",
"description": "CLI script to fetch merged PR comments via GitHub GraphQL",
"type": "project",
"require": {
"php": "^8.1",
"symfony/console": "^7.0",
"symfony/dotenv": "^7.0",
"joomla/http": "^4.0",
"joomla/filter": "^4.0",
"joomla/console": "^4.0",
"joomla/language": "^4.0"
"joomla/http": "^4.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.92"
Expand Down
Loading