Skip to content

Commit

Permalink
Merge pull request #7 from akondas/hide-version
Browse files Browse the repository at this point in the history
Allow to hide version
  • Loading branch information
orediggerco authored Feb 21, 2019
2 parents 5cc2fe6 + 13083e6 commit c47a0ef
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ $ php-legal-licenses generate
> Done!
```

You can also hide dependency version with `--hide-version` option:

```
$ php-legal-licenses generate --hide-version
```



## Example Output
Here is a snippet of the licenses file that would be generated for this utility itself:

Expand Down
2 changes: 1 addition & 1 deletion bin/php-legal-licenses
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if (file_exists(__DIR__.'/../vendor/autoload.php')) {
require __DIR__.'/vendor/autoload.php';
}

$app = new Symfony\Component\Console\Application('PHP Legal Licenses', '1.1.0');
$app = new Symfony\Component\Console\Application('PHP Legal Licenses', '1.2.0');
$app->add(new Comcast\PhpLegalLicenses\Console\GenerateCommand);
$app->add(new Comcast\PhpLegalLicenses\Console\ShowCommand);
$app->run();
14 changes: 11 additions & 3 deletions src/Comcast/PhpLegalLicenses/Command/GenerateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@
namespace Comcast\PhpLegalLicenses\Console;

use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

class GenerateCommand extends DependencyLicenseCommand
{
/**
* @var bool
*/
private $hideVersion = false;

/**
* Configure the command options.
*
Expand All @@ -16,7 +22,8 @@ protected function configure()
{
$this
->setName('generate')
->setDescription('Generate Licenses file from project dependencies.');
->setDescription('Generate Licenses file from project dependencies.')
->addOption('hide-version', 'hv', InputOption::VALUE_NONE, 'Hide dependency version');
}

/**
Expand All @@ -29,6 +36,7 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->hideVersion = $input->getOption('hide-version');
$dependencies = $this->getDependencyList();

$output->writeln('<info>Generating Licenses file...</info>');
Expand Down Expand Up @@ -119,14 +127,14 @@ protected function getFullLicenseText($name)
* @param string $version
* @param string $homepage
* @param string $sha
* @param string $licenceNames
* @param string $licenseNames
* @param string $license
*
* @return string
*/
protected function generateDependencyText($name, $description, $version, $homepage, $sha, $licenseNames, $license)
{
return "### $name (Version $version | $sha)
return "### $name ".($this->hideVersion ? '' : "(Version $version | $sha)")."
$description
Homepage: $homepage
Licenses Used: $licenseNames
Expand Down

0 comments on commit c47a0ef

Please sign in to comment.