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