diff --git a/README.md b/README.md index f87bd64..976c10c 100644 --- a/README.md +++ b/README.md @@ -30,12 +30,11 @@ You need to specify `--url` for the first time, url and optionally login credent $ eventum.phar --url=http://eventum.example.org wr Authentication required (http://eventum.example.org/rpc/xmlrpc.php): Username: glen - Password: + Password: Do you want to store credentials for http://eventum.example.org/rpc/xmlrpc.php ? [Yn] y Elan Ruusamäe Weekly Report 2015.04.27 - 2015.05.03 ``` - ## Commands ## Available commands: @@ -43,3 +42,4 @@ Available commands: - **open-issues** List open issues - **view-issue** Display Issue details - **weekly-report**, **wr** Show weekly reports + - **set-status**, **ss** Set Issue status diff --git a/src/Application.php b/src/Application.php index 0687d89..d2483b6 100644 --- a/src/Application.php +++ b/src/Application.php @@ -52,6 +52,7 @@ protected function getDefaultCommands() $commands[] = new Command\DumpMethodsCommand(); $commands[] = new Command\ConfigCommand(); $commands[] = new Command\AddTimeEntryCommand(); + $commands[] = new Command\SetIssueStatusCommand(); if ('phar:' === substr(__FILE__, 0, 5)) { $commands[] = new Command\SelfUpdateCommand(); diff --git a/src/Command/SetIssueStatusCommand.php b/src/Command/SetIssueStatusCommand.php new file mode 100644 index 0000000..afa40ca --- /dev/null +++ b/src/Command/SetIssueStatusCommand.php @@ -0,0 +1,52 @@ +setName('set-status') + ->setAliases(array('ss')) + ->setDescription('Set Issue status') + ->addArgument( + 'issue_id', + InputArgument::REQUIRED, + 'Issue id' + ) + ->addArgument( + 'status', + InputArgument::REQUIRED, + 'New status for issue' + ) + ->setHelp( + <<%command.full_name% 123 new + +Set issue status. +EOT + ); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $issue_id = (int )$input->getArgument('issue_id'); + $new_status = $input->getArgument('status'); + $client = $this->getClient(); + + $result = $client->setIssueStatus($issue_id, $new_status); + if ($result == 'OK') { + $message = "Status changed to '$new_status' on issue #$issue_id"; + $output->writeln($message); + return 0; + } else { + $output->writeln("$result"); + return 1; + } + } +}