4
4
5
5
namespace App \Command ;
6
6
7
+ use App \Api \Issue \IssueApi ;
8
+ use App \Service \RepositoryProvider ;
7
9
use Symfony \Component \Console \Command \Command ;
8
10
use Symfony \Component \Console \Input \InputArgument ;
9
11
use Symfony \Component \Console \Input \InputInterface ;
17
19
class OpenIssueCommand extends Command
18
20
{
19
21
protected static $ defaultName = 'app:issue:open ' ;
22
+ private $ issueApi ;
23
+ private $ repositoryProvider ;
20
24
21
- public function __construct ()
25
+ public function __construct (RepositoryProvider $ repositoryProvider , IssueApi $ issueApi )
22
26
{
23
27
parent ::__construct ();
28
+ $ this ->issueApi = $ issueApi ;
29
+ $ this ->repositoryProvider = $ repositoryProvider ;
24
30
}
25
31
26
32
protected function configure ()
@@ -34,23 +40,23 @@ protected function execute(InputInterface $input, OutputInterface $output)
34
40
{
35
41
/** @var string $repositoryName */
36
42
$ repositoryName = $ input ->getArgument ('repository ' );
43
+ $ repository = $ this ->repositoryProvider ->getRepository ($ repositoryName );
44
+ if (null === $ repository ) {
45
+ $ output ->writeln ('Repository not configured ' );
46
+ return 1 ;
47
+ }
48
+
37
49
/** @var string $title */
38
50
$ title = $ input ->getArgument ('title ' );
39
51
/** @var string $filePath */
40
52
$ filePath = $ input ->getArgument ('file ' );
53
+
41
54
$ body = file_get_contents ($ filePath );
42
55
if (false === $ body ) {
43
56
return 1 ;
44
57
}
45
58
46
- // These outputs are just debug code
47
- $ output ->writeln ('Will create an issue on ' .$ repositoryName .' with the following: ' );
48
- $ output ->writeln ('------ ' );
49
- $ output ->writeln ($ title );
50
- $ output ->writeln ($ body );
51
- $ output ->writeln ('------ ' );
52
-
53
- // TODO actually open or update an issue
59
+ $ this ->issueApi ->open ($ repository , $ title , $ body , ['help wanted ' ]);
54
60
55
61
return 0 ;
56
62
}
0 commit comments