/** * Retrieves and prints a specified Jira ticket's comemnts * @param InputInterface $input The console input object * @param OutputInterface $output The console output object */ protected function execute(InputInterface $input, OutputInterface $output) { $this->connect($input->getOption('url'), $input->getOption('auth')); $result = Comment::getInstance()->getAll($input->getArgument('issue-key')); if ($result === null || !empty($result->errors)) { $output->writeln(sprintf('<error>Error retrieving comments for ticket `%s`: %s</error>', $input->getArgument('issue-key'), implode((array) $result->errors, PHP_EOL))); } else { $this->prettyPrintComments($result, $output); } }
/** * Adds the comment and outputs the key of the new comment * @param InputInterface $input The console input object * @param OutputInterface $output The console output object */ protected function execute(InputInterface $input, OutputInterface $output) { $this->connect($input->getOption('url'), $input->getOption('auth')); $result = Comment::getInstance()->create($input->getArgument('issue'), $input->getOption('message')); if ($result === null || !empty($result->errors)) { $output->writeln(sprintf('<error>Error creating comment: %s</error>', implode((array) $result->errors, PHP_EOL))); } else { $output->writeln('Comment created: <info>' . $result->id . '</info>'); } }