Skip to content

Commit

Permalink
Enhancement: Show name and author of plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed Dec 29, 2020
1 parent ef1f145 commit 3471652
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 8 deletions.
38 changes: 36 additions & 2 deletions src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,46 @@
*/
final class Application extends Console\Application
{
/**
* @see https://github.com/box-project/box/blob/master/doc/configuration.md#pretty-git-tag-placeholder-git
*
* @var string
*/
private $version = '@git@';

public function getLongVersion(): string
{
$attribution = 'by <info>Andreas Möller</info> and contributors';

$version = $this->getVersion();

if ('' === $version) {
return \sprintf(
'<info>%s</info> %s',
$this->getName(),
$attribution
);
}

return \sprintf(
'%s <info>%s</info> with ergebnis/composer-normalize <info>@git@</info>',
'<info>%s</info> %s %s',
$this->getName(),
$this->getVersion()
$version,
$attribution
);
}

public function getName(): string
{
return 'ergebnis/composer-normalize';
}

public function getVersion(): string
{
if ('@' . 'git@' === $this->version) {
return '';
}

return $this->version;
}
}
8 changes: 8 additions & 0 deletions src/Command/NormalizeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ protected function execute(Console\Input\InputInterface $input, Console\Output\O
{
$io = $this->getIO();

$io->write([
\sprintf(
'Running %s.',
$this->getApplication()->getLongVersion()
),
'',
]);

$indent = null;

try {
Expand Down
7 changes: 1 addition & 6 deletions test/Unit/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,9 @@ final class ApplicationTest extends Framework\TestCase
{
public function testGetLongVersionReturnsVersion(): void
{
$composerApplication = new \Composer\Console\Application();
$application = new Application();

$expected = \sprintf(
'%s <info>%s</info> with ergebnis/composer-normalize <info>@git@</info>',
$composerApplication->getName(),
$composerApplication->getVersion()
);
$expected = '<info>ergebnis/composer-normalize</info> by <info>Andreas Möller</info> and contributors';

self::assertSame($expected, $application->getLongVersion());
}
Expand Down

0 comments on commit 3471652

Please sign in to comment.