Пример #1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $bookmark = new Bookmark();
     $bookmark->command = $input->getArgument('cmd');
     $bookmark->shortcut = $input->getArgument('shortcut');
     $bookmark->description = $input->getOption('description');
     $bookmark->save();
     $output->writeln('   Shortcut: ' . $bookmark->shortcut);
     $output->writeln('    Command: ' . $bookmark->command);
     $output->writeln('Description: ' . $bookmark->description);
     $this->out->success('Bookmark added.');
 }
Пример #2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $shortcut = $input->getArgument('shortcut');
     $count = Bookmark::select()->where('shortcut', $shortcut)->count();
     if ($count === 0) {
         $this->out->error("Command '{$shortcut}' does not exist");
     } else {
         Bookmark::select()->where('shortcut', $shortcut)->delete();
         $this->out->success("{$count} bookmark" . ($count != 1 ? 's' : '') . ' deleted.');
     }
 }
Пример #3
0
 /**
  * @return bool True when there are no bookmarks.
  *
  * @throws \Exception
  */
 private function addWhenEmpty()
 {
     if (Bookmark::select()->count() === 0) {
         $this->out->note("You don't have any commands saved yet. Now showing the help for the add command:");
         $addCommand = $this->getApplication()->find('help');
         $args = array('command' => 'help', 'command_name' => 'add');
         $argsInput = new ArrayInput($args);
         $addCommand->run($argsInput, $this->out);
         return true;
     }
     return false;
 }
Пример #4
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $bookmarks = Bookmark::select()->all();
     $yaml = $this->getOutput($bookmarks);
     $file = $input->getArgument('file');
     if ($file !== null) {
         if (file_put_contents($file, $yaml) !== false) {
             $this->out->success('Exported ' . count($bookmarks) . ' bookmarks to ' . $file);
         } else {
             $this->out->error('Could not write to ' . $file);
         }
     } else {
         $this->out->write($yaml);
     }
 }
Пример #5
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $shortcut = $input->getArgument('shortcut');
     $command = $input->getArgument('cmd');
     $description = $input->getOption('description');
     $bookmark = Bookmark::select()->where('shortcut', $shortcut)->one();
     if ($bookmark === null) {
         throw new \Exception("'{$shortcut}' does not exist. Please try again with a valid shortcut.");
     }
     if ($command !== null) {
         $bookmark->command = $command;
     }
     if ($description !== null) {
         $bookmark->description = $description;
     }
     $bookmark->ts_modified = time();
     $bookmark->save();
     $output->writeln('   Shortcut: ' . $bookmark->shortcut);
     $output->writeln('    Command: ' . $bookmark->command);
     $output->writeln('Description: ' . $bookmark->description);
     $this->out->success('Bookmark updated.');
 }
Пример #6
0
 private function showResults()
 {
     if (count($this->failed) > 0) {
         $this->out->note('Bookmarks that failed to import: ' . count($this->failed));
         Bookmark::table($this->out, $this->failed, array('Error'));
     }
     if (count($this->skipped) > 0) {
         $this->out->note('Bookmarks skipped because of identical shortcuts: ' . count($this->skipped));
         Bookmark::table($this->out, $this->skipped, array('Existing command'));
     }
     if (count($this->imported) > 0) {
         $this->out->success('Bookmarks successfully imported: ' . count($this->imported));
         Bookmark::table($this->out, $this->imported);
     } else {
         $this->out->note('No bookmarks were imported.');
     }
 }
Пример #7
0
 public function __construct(Client $client)
 {
     $this->client = $client;
     $sortColumns = array_keys(Bookmark::select()->toAssoc());
     $this->supportedSettings = array('ff.limit' => array('desc' => 'Limit amount of results (> 0 or 0 for no limit)', 'validation' => array(v::int()->min(0, true)), 'default' => '0'), 'ff.sort' => array('desc' => 'Sort order of results (' . implode($sortColumns, ', ') . ')', 'validation' => array(v::in($sortColumns)->notEmpty()), 'default' => 'hit_count'), 'ff.interactive' => array('desc' => 'Ask for missing input interactively (0 never, 1 always)', 'validation' => array(v::in(array('0', '1'))), 'default' => '1'), 'ff.color' => array('desc' => 'Enable color output on supported systems (0/1)', 'validation' => array(v::in(array('0', '1'))), 'default' => '1'));
 }
Пример #8
0
 /**
  * Tears down the fixture, for example, close a network connection.
  * This method is called after a test is executed.
  */
 protected function tearDown()
 {
     Bookmark::select()->delete();
 }