12
12
use PHPSemVerChecker \SemanticVersioning \Level ;
13
13
use PHPSemVerCheckerGit \Filter \SourceFilter ;
14
14
use RuntimeException ;
15
- use Symfony \Component \Console \Command \Command ;
16
15
use Symfony \Component \Console \Helper \ProgressBar ;
17
16
use Symfony \Component \Console \Input \InputArgument ;
18
17
use Symfony \Component \Console \Input \InputInterface ;
21
20
use vierbergenlars \SemVer \expression as SemanticExpression ;
22
21
use vierbergenlars \SemVer \version as SemanticVersion ;
23
22
24
- class SuggestCommand extends Command
23
+ class SuggestCommand extends BaseCommand
25
24
{
26
25
protected function configure ()
27
26
{
@@ -34,6 +33,7 @@ protected function configure()
34
33
new InputOption ('against ' , 'a ' , InputOption::VALUE_REQUIRED , 'What to test against the tag (HEAD by default) ' ),
35
34
new InputOption ('allow-detached ' , 'd ' , InputOption::VALUE_NONE , 'Allow suggest to start from a detached HEAD ' ),
36
35
new InputOption ('details ' , null , InputOption::VALUE_NONE , 'Report the changes on which the suggestion is based ' ),
36
+ new InputOption ('config ' , null , InputOption::VALUE_REQUIRED , 'A configuration file to configure php-semver-checker-git ' ),
37
37
]);
38
38
}
39
39
@@ -42,14 +42,14 @@ protected function execute(InputInterface $input, OutputInterface $output)
42
42
$ startTime = microtime (true );
43
43
44
44
$ targetDirectory = getcwd ();
45
- $ tag = $ input -> getOption ('tag ' );
46
- $ against = $ input -> getOption ('against ' ) ?: 'HEAD ' ;
45
+ $ tag = $ this -> config -> get ('tag ' );
46
+ $ against = $ this -> config -> get ('against ' ) ?: 'HEAD ' ;
47
47
48
- $ includeBefore = $ input -> getOption ('include-before ' );
49
- $ excludeBefore = $ input -> getOption ('exclude-before ' );
48
+ $ includeBefore = $ this -> config -> get ('include-before ' );
49
+ $ excludeBefore = $ this -> config -> get ('exclude-before ' );
50
50
51
- $ includeAfter = $ input -> getOption ('include-after ' );
52
- $ excludeAfter = $ input -> getOption ('exclude-after ' );
51
+ $ includeAfter = $ this -> config -> get ('include-after ' );
52
+ $ excludeAfter = $ this -> config -> get ('exclude-after ' );
53
53
54
54
$ client = new Client ();
55
55
@@ -80,7 +80,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
80
80
81
81
$ initialBranch = $ repository ->getCurrentBranch ();
82
82
83
- if ( ! $ input -> getOption ('allow-detached ' ) && ! $ initialBranch ) {
83
+ if ( ! $ this -> config -> get ('allow-detached ' ) && ! $ initialBranch ) {
84
84
$ output ->writeln ('<error>You are on a detached HEAD, aborting.</error> ' );
85
85
$ output ->writeln ('<info>If you still wish to run against a detached HEAD, use --allow-detached.</info> ' );
86
86
return -1 ;
@@ -146,7 +146,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
146
146
$ output ->writeln ('<info>Initial semantic version: ' . $ tag . '</info> ' );
147
147
$ output ->writeln ('<info>Suggested semantic version: ' . $ newTag . '</info> ' );
148
148
149
- if ($ input -> getOption ('details ' )) {
149
+ if ($ this -> config -> get ('details ' )) {
150
150
$ reporter = new Reporter ($ report );
151
151
$ reporter ->output ($ output );
152
152
}
0 commit comments