1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Scrumban\Command; |
4
|
|
|
|
5
|
|
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; |
6
|
|
|
|
7
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
8
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
9
|
|
|
use Symfony\Component\Console\Input\InputOption; |
10
|
|
|
use Symfony\Component\Console\Question\Question; |
11
|
|
|
|
12
|
|
|
use Scrumban\Manager\SprintManager; |
13
|
|
|
|
14
|
|
|
class SprintCreationCommand extends ContainerAwareCommand |
15
|
|
|
{ |
16
|
|
|
protected function configure() |
17
|
|
|
{ |
18
|
|
|
$this |
19
|
|
|
->setName('scrumban:sprint:create') |
20
|
|
|
->setDescription('Create a new sprint') |
21
|
|
|
->addOption('begin', null, InputOption::VALUE_OPTIONAL, 'Sprint begin date') |
22
|
|
|
->addOption('end', null, InputOption::VALUE_OPTIONAL, 'Sprint end date') |
23
|
|
|
; |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
27
|
|
|
{ |
28
|
|
|
$helper = $this->getHelper('question'); |
29
|
|
|
if(($begin = $input->getOption('begin')) === null) { |
30
|
|
|
$begin = $helper->ask($input, $output, new Question('Please enter the sprint begin date: ')); |
31
|
|
|
} |
32
|
|
|
if(($end = $input->getOption('end')) === null) { |
33
|
|
|
$end = $helper->ask($input, $output, new Question('Please enter the sprint end date: ')); |
34
|
|
|
} |
35
|
|
|
$sprint = $this->getContainer()->get(SprintManager::class)->createSprint(new \DateTime($begin), new \DateTime($end)); |
36
|
|
|
|
37
|
|
|
$output->writeln( |
38
|
|
|
"<fg=white;bg=green>\n\n Sprint {$sprint->getId()} created ! It will be active from {$sprint->getBeginAt()->format('c')} to {$sprint->getEndedAt()->format('c')}\n</>\n" |
39
|
|
|
); |
40
|
|
|
} |
41
|
|
|
} |