Skip to content

Commit

Permalink
Merge pull request #1 from IonBazan/feature/arguments
Browse files Browse the repository at this point in the history
add support for base and target arguments
  • Loading branch information
IonBazan authored Apr 8, 2021
2 parents 7c31597 + 0bb386a commit e6703e6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ composer diff # Displays packages changed in current git tree compared with HEAD
## Advanced usage

```shell script
composer diff -b master:composer.lock -t develop:composer.lock -p # Compare master and develop branches, including platform dependencies
composer diff master # Compare current composer.lock with the one on master branch
composer diff master:composer.lock develop:composer.lock -p # Compare master and develop branches, including platform dependencies
composer diff --no-dev # ignore dev dependencies
composer diff -p # include platform dependencies
composer diff -f json # Output as JSON instead of table
Expand Down
7 changes: 5 additions & 2 deletions src/Command/DiffCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use IonBazan\ComposerDiff\Formatter\MarkdownTableFormatter;
use IonBazan\ComposerDiff\PackageDiff;
use IonBazan\ComposerDiff\Url\GeneratorContainer;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
Expand Down Expand Up @@ -43,6 +44,8 @@ protected function configure()
{
$this->setName('diff')
->setDescription('Displays package diff')
->addArgument('base', InputArgument::OPTIONAL, 'Base composer.lock file path or git ref')
->addArgument('target', InputArgument::OPTIONAL, 'Target composer.lock file path or git ref')
->addOption('base', 'b', InputOption::VALUE_REQUIRED, 'Base composer.lock file path or git ref', 'HEAD:composer.lock')
->addOption('target', 't', InputOption::VALUE_REQUIRED, 'Target composer.lock file path or git ref', 'composer.lock')
->addOption('no-dev', null, InputOption::VALUE_NONE, 'Ignore dev dependencies')
Expand All @@ -59,8 +62,8 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$base = $input->getOption('base');
$target = $input->getOption('target');
$base = $input->getArgument('base') !== null ? $input->getArgument('base') : $input->getOption('base');
$target = $input->getArgument('target') !== null ? $input->getArgument('target') :$input->getOption('target');
$withPlatform = $input->getOption('with-platform');
$withUrls = $input->getOption('with-links');
$this->gitlabDomains = array_merge($this->gitlabDomains, $input->getOption('gitlab-domains'));
Expand Down
19 changes: 19 additions & 0 deletions tests/Integration/DiffCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,25 @@ public function commandArgumentsDataProvider()
'--no-dev' => null,
),
),
'no-dev with arguments' => array(
<<<OUTPUT
| Prod Packages | Operation | Base | Target |
|------------------------------------|-----------|---------|---------|
| psr/event-dispatcher | New | - | 1.0.0 |
| symfony/deprecation-contracts | New | - | v2.1.2 |
| symfony/event-dispatcher | Upgraded | v2.8.52 | v5.1.2 |
| symfony/event-dispatcher-contracts | New | - | v2.1.2 |
| symfony/polyfill-php80 | New | - | v1.17.1 |
OUTPUT
,
array(
'base' => __DIR__.'/../fixtures/base/composer.lock',
'target' => __DIR__.'/../fixtures/target/composer.lock',
'--no-dev' => null,
),
),
'no-prod' => array(
<<<OUTPUT
| Dev Packages | Operation | Base | Target |
Expand Down

0 comments on commit e6703e6

Please sign in to comment.