Skip to content

Commit c47a0ef

Browse files
authored
Merge pull request #7 from akondas/hide-version
Allow to hide version
2 parents 5cc2fe6 + 13083e6 commit c47a0ef

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ $ php-legal-licenses generate
3232
> Done!
3333
```
3434

35+
You can also hide dependency version with `--hide-version` option:
36+
37+
```
38+
$ php-legal-licenses generate --hide-version
39+
```
40+
41+
42+
3543
## Example Output
3644
Here is a snippet of the licenses file that would be generated for this utility itself:
3745

bin/php-legal-licenses

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ if (file_exists(__DIR__.'/../vendor/autoload.php')) {
99
require __DIR__.'/vendor/autoload.php';
1010
}
1111

12-
$app = new Symfony\Component\Console\Application('PHP Legal Licenses', '1.1.0');
12+
$app = new Symfony\Component\Console\Application('PHP Legal Licenses', '1.2.0');
1313
$app->add(new Comcast\PhpLegalLicenses\Console\GenerateCommand);
1414
$app->add(new Comcast\PhpLegalLicenses\Console\ShowCommand);
1515
$app->run();

src/Comcast/PhpLegalLicenses/Command/GenerateCommand.php

+11-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,16 @@
33
namespace Comcast\PhpLegalLicenses\Console;
44

55
use Symfony\Component\Console\Input\InputInterface;
6+
use Symfony\Component\Console\Input\InputOption;
67
use Symfony\Component\Console\Output\OutputInterface;
78

89
class GenerateCommand extends DependencyLicenseCommand
910
{
11+
/**
12+
* @var bool
13+
*/
14+
private $hideVersion = false;
15+
1016
/**
1117
* Configure the command options.
1218
*
@@ -16,7 +22,8 @@ protected function configure()
1622
{
1723
$this
1824
->setName('generate')
19-
->setDescription('Generate Licenses file from project dependencies.');
25+
->setDescription('Generate Licenses file from project dependencies.')
26+
->addOption('hide-version', 'hv', InputOption::VALUE_NONE, 'Hide dependency version');
2027
}
2128

2229
/**
@@ -29,6 +36,7 @@ protected function configure()
2936
*/
3037
protected function execute(InputInterface $input, OutputInterface $output)
3138
{
39+
$this->hideVersion = $input->getOption('hide-version');
3240
$dependencies = $this->getDependencyList();
3341

3442
$output->writeln('<info>Generating Licenses file...</info>');
@@ -119,14 +127,14 @@ protected function getFullLicenseText($name)
119127
* @param string $version
120128
* @param string $homepage
121129
* @param string $sha
122-
* @param string $licenceNames
130+
* @param string $licenseNames
123131
* @param string $license
124132
*
125133
* @return string
126134
*/
127135
protected function generateDependencyText($name, $description, $version, $homepage, $sha, $licenseNames, $license)
128136
{
129-
return "### $name (Version $version | $sha)
137+
return "### $name ".($this->hideVersion ? '' : "(Version $version | $sha)")."
130138
$description
131139
Homepage: $homepage
132140
Licenses Used: $licenseNames

0 commit comments

Comments
 (0)