11 public function __construct($cfg)
16 public static function opts(\Console_CommandLine $optParser)
18 $cmd = $optParser->addCommand('note');
23 'long_name' => '--files',
24 'description' => 'Files to upload',
25 'help_name' => 'PATH',
26 'action' => 'StoreArray',
35 'description' => 'Post text',
40 public function run($command)
42 $req = new Request($this->cfg->host, $this->cfg);
43 $req->req->addPostParameter('h', 'entry');
44 $req->req->addPostParameter('content', $command->args['text']);
46 $files = $command->options['files'];
52 foreach ($files as $filePath) {
53 if (!file_exists($filePath)) {
54 Log::err('File does not exist: ' . $filePath);
58 $fileList[$type][] = $filePath;
60 foreach ($fileList as $type => $filePaths) {
61 if (count($filePaths) == 1) {
62 $req->addUpload($type, reset($filePaths));
63 } else if (count($filePaths) > 0) {
64 $req->addUpload($type, $filePaths);
69 $postUrl = $res->getHeader('Location');
70 echo "Post created at server\n";