Exemple #1
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if ($slot_id = $input->getArgument('slot_id')) {
         $slot = $this->repository->slot($slot_id);
     } else {
         $slot = $this->repository->latest();
     }
     if ($slot) {
         $details = $this->connector->ticketDetails($slot->tid);
         list($slot_id, $continued) = $this->repository->start($slot->tid, $slot->comment, $slot->id);
         $output->writeln(sprintf('<bg=blue;fg=white;options=bold>[%s]</> <comment>%s</comment> entry for <info>%d</info>: %s [slot:<comment>%d</comment>]', (new \DateTime())->format('h:i'), $continued ? 'Continued' : 'Started new', $slot->tid, $details->getTitle(), $slot_id));
         return;
     }
     $output->writeln('<error>Could not find the slot to continue</error>');
 }
Exemple #2
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $ticket_id = $input->getArgument('issue_number');
     if ($alias = $this->repository->loadAlias($ticket_id)) {
         $ticket_id = $alias;
     }
     if ($title = $this->connector->ticketDetails($ticket_id)) {
         if ($stop = $this->repository->stop()) {
             $stopped = $this->connector->ticketDetails($stop->tid);
             $output->writeln(sprintf('Closed slot <comment>%d</comment> against ticket <info>%d</info>: %s, duration <info>%s</info>', $stop->id, $stop->tid, $stopped->getTitle(), Formatter::formatDuration($stop->duration)));
         }
         try {
             list($slot_id, $continued) = $this->repository->start($ticket_id, $input->getArgument('comment'));
             $output->writeln(sprintf('<bg=blue;fg=white;options=bold>[%s]</> <comment>%s</comment> entry for <info>%d</info>: %s [slot:<comment>%d</comment>]', (new \DateTime())->format('h:i'), $continued ? 'Continued' : 'Started new', $ticket_id, $title->getTitle(), $slot_id));
             if ($input->getOption('status')) {
                 if ($this->connector->setInProgress($ticket_id, $assign = $input->getOption('assign'))) {
                     $output->writeln(sprintf('Ticket <comment>%s</comment> set to in-progress.', $ticket_id));
                     if ($assign) {
                         $output->writeln(sprintf('Ticket <comment>%s</comment> assigned to you.', $ticket_id));
                     }
                 } else {
                     $output->writeln('<error>Could not update ticket status</error>');
                     if ($assign) {
                         $output->writeln('<error>Could not assign ticket</error>');
                     }
                 }
             } elseif ($input->getOption('assign')) {
                 if ($this->connector->assign($ticket_id)) {
                     $output->writeln(sprintf('Ticket <comment>%s</comment> assigned to you.', $ticket_id));
                 } else {
                     $output->writeln('<error>Could not assign ticket</error>');
                 }
             }
         } catch (\Exception $e) {
             $output->writeln(sprintf('<error>Error creating slot: %s</error>', $e->getMessage()));
         }
     } else {
         $output->writeln('<error>Error: no such ticket id or access denied</error>');
     }
 }