4 class Command_Bookmark extends Command_AbstractProps
6 public static function opts(\Console_CommandLine $optParser)
8 $cmd = $optParser->addCommand('bookmark');
9 static::addOptHtml($cmd);
10 static::optsGeneric($cmd);
15 'description' => 'URL to bookmark',
23 'description' => 'Bookmark text',
28 public function run(\Console_CommandLine_Result $cmdRes)
30 $url = Validator::url($cmdRes->args['url'], 'url');
35 $req = new Request($this->cfg->host, $this->cfg);
36 $req->setType('entry');
37 $req->addProperty('bookmark-of', $url);
39 if ($cmdRes->args['text']) {
40 $req->addContent($cmdRes->args['text'], $cmdRes->options['html']);
44 $this->handleGenericOptions($cmdRes, $req);
47 $postUrl = $res->getHeader('Location');
48 if ($postUrl === null) {
49 Log::err('Error: Server sent no "Location" header and said:');
50 Log::err($res->getBody());
53 Log::info('Bookmark created at server');