From 9a5804a75a897c11fe51bb8bb32be36e120ae30a Mon Sep 17 00:00:00 2001 From: Arkadiusz Kondas Date: Wed, 13 Feb 2019 11:20:01 +0100 Subject: [PATCH 1/3] Allow to hide version --- README.md | 8 ++++++++ .../PhpLegalLicenses/Command/GenerateCommand.php | 15 ++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) 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/src/Comcast/PhpLegalLicenses/Command/GenerateCommand.php b/src/Comcast/PhpLegalLicenses/Command/GenerateCommand.php index ed716445..db12a90e 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,9 @@ 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 +37,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 +128,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 From e7ba83b5c6e9c300b63db399609c6b7f297cf9af Mon Sep 17 00:00:00 2001 From: Arkadiusz Kondas Date: Wed, 13 Feb 2019 11:23:51 +0100 Subject: [PATCH 2/3] Apply code style fixes --- src/Comcast/PhpLegalLicenses/Command/GenerateCommand.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Comcast/PhpLegalLicenses/Command/GenerateCommand.php b/src/Comcast/PhpLegalLicenses/Command/GenerateCommand.php index db12a90e..5c8db5af 100644 --- a/src/Comcast/PhpLegalLicenses/Command/GenerateCommand.php +++ b/src/Comcast/PhpLegalLicenses/Command/GenerateCommand.php @@ -23,8 +23,7 @@ protected function configure() $this ->setName('generate') ->setDescription('Generate Licenses file from project dependencies.') - ->addOption('hide-version', 'hv', InputOption::VALUE_NONE, 'Hide dependency version') - ; + ->addOption('hide-version', 'hv', InputOption::VALUE_NONE, 'Hide dependency version'); } /** @@ -135,7 +134,7 @@ protected function getFullLicenseText($name) */ protected function generateDependencyText($name, $description, $version, $homepage, $sha, $licenseNames, $license) { - return "### $name ".($this->hideVersion ? "" : "(Version $version | $sha)"). " + return "### $name ".($this->hideVersion ? '' : "(Version $version | $sha)")." $description Homepage: $homepage Licenses Used: $licenseNames From 13083e601f09801b2aa4ac5c897c2f7337ad6694 Mon Sep 17 00:00:00 2001 From: Arkadiusz Kondas Date: Wed, 13 Feb 2019 11:38:16 +0100 Subject: [PATCH 3/3] Increase version number --- bin/php-legal-licenses | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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();