-
Notifications
You must be signed in to change notification settings - Fork 0
/
sprintlist.php
executable file
·73 lines (59 loc) · 1.81 KB
/
sprintlist.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/php
<?php
require 'vendor/autoload.php';
class SprintList extends AbstractCLI
{
/**
* Register options and arguments on the given $options object
*
* @param \splitbrain\phpcli\Options $options
* @return void
*/
protected function setup(\splitbrain\phpcli\Options $options)
{
$options->setHelp('Print Issues in the given sprint by assignee as DokuWiki list');
$options->registerArgument('sprints...', 'The ID of the sprints');
}
/**
* Your main program
*
* Arguments and options have been parsed when this is run
*
* @param \splitbrain\phpcli\Options $options
* @return void
*/
protected function main(\splitbrain\phpcli\Options $options)
{
$this->loadCredentials();
$sprints = $options->getArgs();
$sprints = array_map('intval', $sprints);
$this->printIssues($sprints);
}
/**
* Print the issues for the given sprints
*
* @param int[] $sprints
*/
protected function printIssues($sprints)
{
$data = array();
$sprints = join(',', $sprints);
$issues = $this->jiraApi('/rest/api/latest/search/', "resolution = Unresolved AND sprint IN ($sprints)");
foreach ($issues['issues'] as $issue) {
$ticket = $issue['key'];
$title = $issue['fields']['summary'];
$user = $issue['fields']['assignee']['displayName'];
if(!isset($data[$user])) $data[$user] = array();
$data[$user][$ticket] = $title;
}
foreach($data as $user => $info) {
echo " * $user\n";
foreach($info as $ticket => $title) {
echo " - [[jira>$ticket]] $title\n";
}
}
echo "\n";
}
}
$cli = new SprintList();
$cli->run();