4 class Command_Bookmark extends Command_AbstractProps
6 public static function opts(\Console_CommandLine $optParser)
8 $cmd = $optParser->addCommand('bookmark');
9 static::optsGeneric($cmd);
14 'description' => 'URL to bookmark',
22 'description' => 'Bookmark text',
27 public function run(\Console_CommandLine_Result $cmdRes)
29 $url = Validator::url($cmdRes->args['url'], 'url');
34 $req = new Request($this->cfg->host, $this->cfg);
35 $req->req->addPostParameter('h', 'entry');
36 $req->req->addPostParameter('bookmark-of', $url);
38 if ($cmdRes->args['text']) {
39 $req->req->addPostParameter('content', $cmdRes->args['text']);
43 $this->handleGenericOptions($cmdRes, $req);
46 $postUrl = $res->getHeader('Location');
47 if ($postUrl === null) {
48 Log::err('Error: Server sent no "Location" header and said:');
49 Log::err($res->getBody());
52 Log::info('Bookmark created at server');