Skip to content

Commit e72882d

Browse files
committed
add more verbose usage instructions
1 parent be4aabc commit e72882d

File tree

2 files changed

+61
-18
lines changed

2 files changed

+61
-18
lines changed

README.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,23 @@
1010

1111
Generates packages changes report in Markdown format by comparing `composer.lock` files. Compares with last-commited changes by default.
1212

13+
## Now available as [GitHub Action](https://github.com/marketplace/actions/composer-diff)!
14+
1315
![preview](preview.png)
1416

17+
# Installation
18+
19+
```shell script
20+
composer global require ion-bazan/composer-diff
21+
```
22+
23+
# Usage
24+
25+
```shell script
26+
composer diff # Displays packages changed in current git tree compared with HEAD
27+
composer diff --help # Display detailed usage instructions
28+
```
29+
1530
## Example output
1631

1732
| Prod Packages | Operation | Base | Target |
@@ -46,18 +61,6 @@ Generates packages changes report in Markdown format by comparing `composer.lock
4661
| phpunit/php-invoker | Removed | 3.0.1 | - |
4762
| sebastian/code-unit | Removed | 1.0.3 | - |
4863

49-
# Installation
50-
51-
```shell script
52-
composer global require ion-bazan/composer-diff
53-
```
54-
55-
# Usage
56-
57-
```shell script
58-
composer diff # Displays packages changed in current git tree compared with HEAD
59-
```
60-
6164
## Options
6265

6366
- `--base` (`-b`) - path, URL or git ref to original `composer.lock` file
@@ -94,6 +97,7 @@ This package offers:
9497
- Both standalone executable and composer plugin interface - you choose how you want to use it.
9598
- Allows generating reports in several formats.
9699
- Extra Gitlab domains support.
100+
- [GitHub Action](https://github.com/marketplace/actions/composer-diff) with example workflow
97101
- 100% test coverage.
98102
- MIT license.
99103

src/Command/DiffCommand.php

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,56 @@ public function __construct(PackageDiff $packageDiff, array $gitlabDomains = arr
4343
protected function configure()
4444
{
4545
$this->setName('diff')
46-
->setDescription('Displays package diff')
47-
->addArgument('base', InputArgument::OPTIONAL, 'Base composer.lock file path or git ref')
48-
->addArgument('target', InputArgument::OPTIONAL, 'Target composer.lock file path or git ref')
49-
->addOption('base', 'b', InputOption::VALUE_REQUIRED, 'Base composer.lock file path or git ref', 'HEAD:composer.lock')
50-
->addOption('target', 't', InputOption::VALUE_REQUIRED, 'Target composer.lock file path or git ref', 'composer.lock')
46+
->setDescription('Compares composer.lock files and shows package changes')
47+
->addArgument('base', InputArgument::OPTIONAL, 'Base (original) composer.lock file path or git ref')
48+
->addArgument('target', InputArgument::OPTIONAL, 'Target (modified) composer.lock file path or git ref')
49+
->addOption('base', 'b', InputOption::VALUE_REQUIRED, 'Base (original) composer.lock file path or git ref', 'HEAD:composer.lock')
50+
->addOption('target', 't', InputOption::VALUE_REQUIRED, 'Target (modified) composer.lock file path or git ref', 'composer.lock')
5151
->addOption('no-dev', null, InputOption::VALUE_NONE, 'Ignore dev dependencies')
5252
->addOption('no-prod', null, InputOption::VALUE_NONE, 'Ignore prod dependencies')
5353
->addOption('with-platform', 'p', InputOption::VALUE_NONE, 'Include platform dependencies (PHP version, extensions, etc.)')
5454
->addOption('with-links', 'l', InputOption::VALUE_NONE, 'Include compare/release URLs')
5555
->addOption('format', 'f', InputOption::VALUE_REQUIRED, 'Output format (mdtable, mdlist, json)', 'mdtable')
56-
->addOption('gitlab-domains', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Gitlab domains', array())
56+
->addOption('gitlab-domains', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Extra Gitlab domains (inherited from Composer config by default)', array())
57+
->setHelp(<<<'EOF'
58+
The <comment>%command.name%</comment> command displays all dependency changes between two <info>composer.lock</info> files.
59+
By default, it will compare current filesystem changes with git <info>HEAD</info>:
60+
61+
<comment>%command.full_name%</comment>
62+
63+
To compare with specific branch, pass its name as argument:
64+
65+
<comment>%command.full_name% master</comment>
66+
67+
You can specify any valid git refs to compare with:
68+
69+
<comment>%command.full_name% HEAD~3 be4aabc</comment>
70+
71+
You can also use more verbose syntax for <info>base</info> and <info>target</info> options:
72+
73+
<comment>%command.full_name% --base master --target composer.lock</comment>
74+
75+
To compare files in specific path, use following syntax:
76+
77+
<comment>%command.full_name% master:subdirectory/composer.lock /path/to/another/composer.lock</comment>
78+
79+
By default, <info>platform</info> dependencies are hidden. Add <comment>--with-platform</comment> option to include them in the report:
80+
81+
<comment>%command.full_name% --with-platform</comment>
82+
83+
Use <comment>--with-links</comment> to include release and compare URLs in the report:
84+
85+
<comment>%command.full_name% --with-links</comment>
86+
87+
You can customize output format by specifying it with <comment>--format</comment> option. Choose between <info>mdtable</info>, <info>mdlist</info> and <info>json</info>:
88+
89+
<comment>%command.full_name% --format=json</comment>
90+
91+
Hide <info>dev</info> dependencies using <comment>--no-dev</comment> option:
92+
93+
<comment>%command.full_name% --no-dev</comment>
94+
EOF
95+
)
5796
;
5897
}
5998

0 commit comments

Comments
 (0)