diff --git a/README.md b/README.md index 815057e7..7c8ceec0 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/bin/php-legal-licenses b/bin/php-legal-licenses index bfd5f2f3..577abb85 100755 --- a/bin/php-legal-licenses +++ b/bin/php-legal-licenses @@ -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(); diff --git a/src/Comcast/PhpLegalLicenses/Command/GenerateCommand.php b/src/Comcast/PhpLegalLicenses/Command/GenerateCommand.php index ed716445..5c8db5af 100644 --- a/src/Comcast/PhpLegalLicenses/Command/GenerateCommand.php +++ b/src/Comcast/PhpLegalLicenses/Command/GenerateCommand.php @@ -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. * @@ -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'); } /** @@ -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('Generating Licenses file...'); @@ -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