Exemplo n.º 1
0
 /**
  * Execute this command according to given switches and parameters.
  *
  * @param InputInterface  $input
  * @param OutputInterface $output
  * @return int
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $index = $input->getArgument('index');
     $closed = $input->getOption('closed');
     $client = Auth::getClient();
     if ($index === null) {
         $table = new Table($output);
         $table->setStyle('compact');
         $table->setHeaders(['', 'Cards', 'List', 'Board']);
         $i = 1;
         foreach ($client->member()->cards()->all('me') as $card) {
             if (!$closed && $card['closed']) {
                 continue;
             }
             $board = $client->boards()->show($card['idBoard']);
             $list = $client->lists()->show($card['idList']);
             $background = $board['prefs']['background'];
             $table->addRow([sprintf('%2d', $i++), mb_substr($card['name'], 0, 45, 'UTF-8'), $list['name'], $this->colorTag(mb_substr($board['name'], 0, 20, 'UTF-8'), $background)]);
         }
         $table->render();
     } else {
         $i = 1;
         foreach ($client->member()->cards()->all('me') as $card) {
             if (!$closed && $card['closed']) {
                 continue;
             }
             if ($i++ === (int) $index) {
                 break;
             }
         }
         $checklists = array_map(function ($id) use($client) {
             return $client->checklists()->show($id);
         }, $card['idChecklists']);
         $this->addOutputStyles($output);
         $text = $card['desc'];
         $output->writeln("<info>{$card['name']}</>");
         $output->writeln($this->formatText($text));
         $output->writeln($this->formatChecklists($checklists));
     }
     return 0;
 }
Exemplo n.º 2
0
 /**
  * Execute this command according to given switches and parameters.
  *
  * @param InputInterface  $input
  * @param OutputInterface $output
  * @return int
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $private = $input->getOption('private');
     $closed = $input->getOption('closed');
     $client = Auth::getClient();
     $table = new Table($output);
     $table->setStyle('compact');
     $table->setHeaders(['Board', 'Cards', 'Flags']);
     foreach ($client->member()->boards()->all('me') as $board) {
         if (!$closed && $board['closed']) {
             continue;
         }
         if ($private && $board['prefs']['permissionLevel'] !== 'private') {
             continue;
         }
         $background = $board['prefs']['background'];
         $cardCount = count($client->board($board['id'])->cards()->filter($board['id'], $closed ? 'all' : 'open'));
         $flags = [$board['closed'] ? 'Closed' : false, $board['prefs']['permissionLevel'] === 'private' ? 'Private' : false, $board['starred'] ? 'Starred' : false, $board['pinned'] ? 'Pinned' : false];
         $table->addRow([$this->colorTag($board['name'], $background), sprintf('%5d', $cardCount), implode(', ', array_filter($flags))]);
     }
     $table->render();
     return 0;
 }