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.'); } }
/** * @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; }
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); } }
/** * @param array $map */ private function importMap($map) { $bookmark = new Bookmark(); $bookmark->hydrate($map); $existing = Bookmark::select()->where('shortcut', $bookmark->shortcut)->one(); if ($existing !== null) { $bookmark->setExtra('Existing command', $existing->command); $this->skipped[] = $bookmark; return; } try { $bookmark->save(); $this->imported[] = $bookmark; } catch (\Exception $e) { $bookmark->setExtra('Error', $e->getMessage()); $this->failed[] = $bookmark; } }
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.'); }
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')); }
/** * 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(); }