Skip to content

Commit

Permalink
feat: add conventional-commits console command
Browse files Browse the repository at this point in the history
  • Loading branch information
ramsey committed Aug 13, 2020
1 parent 402eaaa commit f3d3247
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 3 deletions.
58 changes: 58 additions & 0 deletions bin/conventional-commits
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env php
<?php

/**
* This file is part of ramsey/conventional-commits
*
* ramsey/conventional-commits is open source software: you can distribute it
* and/or modify it under the terms of the MIT License (the "License"). You may
* not use this file except in compliance with the License.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
* @license https://opensource.org/licenses/MIT MIT License
*/

declare(strict_types=1);

use Ramsey\ConventionalCommits\Console\Command\PrepareCommand;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;

(static function (array $argv): void {
$composerAutoloadLocations = [
__DIR__ . '/../autoload.php',
__DIR__ . '/../vendor/autoload.php',
__DIR__ . '/../../../autoload.php',
];

foreach ($composerAutoloadLocations as $file) {
if (file_exists($file)) {
$composerAutoloader = $file;

break;
}
}
unset($file);

if (!isset($composerAutoloader)) {
fwrite(
STDERR,
'To execute this command, please install Composer and run \'composer install\'.' . PHP_EOL
. 'For more information, go to https://getcomposer.org' . PHP_EOL,
);

exit(1);
}

require $composerAutoloader;

$application = new Application('Conventional Commits');
$application->add(new PrepareCommand());
$application->run(new ArgvInput($argv));
})($argv);
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
"vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest.php"
]
},
"bin": [
"bin/conventional-commits"
],
"scripts": {
"post-autoload-dump": "captainhook install --ansi -f -s",
"br:analyze": [
Expand Down
7 changes: 4 additions & 3 deletions src/ConventionalCommits/Console/Command/PrepareCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,11 @@ public function getMessage(): ?Message
protected function configure(): void
{
$this
->setDescription('Prepares a commit message.')
->setDescription('Prepares a commit message conforming to Conventional Commits')
->setHelp(
'This command helps prepare a commit message according to the '
. 'Conventional Commits specification.',
'This command interactively helps prepare a commit message '
. 'according to the Conventional Commits specification. For more '
. 'information, see https://www.conventionalcommits.org.',
);
}

Expand Down

0 comments on commit f3d3247

Please sign in to comment.