git.cweiske.de
/
shpub.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
move constructor to command base class
[shpub.git]
/
src
/
shpub
/
Command
/
Reply.php
diff --git
a/src/shpub/Command/Reply.php
b/src/shpub/Command/Reply.php
index 622361a9d81f1aaa31b474e0088106a68ef5d2dd..493d58716808de438821c7d269c57f96f1d9b78b 100644
(file)
--- a/
src/shpub/Command/Reply.php
+++ b/
src/shpub/Command/Reply.php
@@
-1,21
+1,12
@@
<?php
namespace shpub;
<?php
namespace shpub;
-class Command_Reply
+class Command_Reply
extends Command_AbstractProps
{
{
- /**
- * @var Config
- */
- protected $cfg;
-
- public function __construct($cfg)
- {
- $this->cfg = $cfg;
- }
-
public static function opts(\Console_CommandLine $optParser)
{
$cmd = $optParser->addCommand('reply');
public static function opts(\Console_CommandLine $optParser)
{
$cmd = $optParser->addCommand('reply');
+ static::optsGeneric($cmd);
$cmd->addArgument(
'url',
[
$cmd->addArgument(
'url',
[
@@
-32,26
+23,25
@@
class Command_Reply
]
);
}
]
);
}
- public function run($url, $text)
+
+ public function run(\Console_CommandLine_Result $cmdRes)
{
{
- $url = Validator::url($
url
, 'url');
+ $url = Validator::url($
cmdRes->args['url']
, 'url');
if ($url === false) {
exit(10);
}
if ($url === false) {
exit(10);
}
- $body = http_build_query(
- [
- 'h' => 'entry',
- 'content' => $text,
- 'in-reply-to' => $url,
- ]
- );
-
$req = new Request($this->cfg->host, $this->cfg);
$req = new Request($this->cfg->host, $this->cfg);
- $res = $req->send($body);
+ $req->req->addPostParameter('h', 'entry');
+ $req->req->addPostParameter('content', implode(' ', $cmdRes->args['text']));
+ $req->req->addPostParameter('in-reply-to', $url);
+
+ $this->handleGenericOptions($cmdRes, $req);
+ $res = $req->send();
+
$postUrl = $res->getHeader('Location');
$postUrl = $res->getHeader('Location');
-
echo "Reply created at server\n"
;
-
echo $postUrl . "\n"
;
+
Log::info('Reply created at server')
;
+
Log::msg($postUrl)
;
}
}
?>
}
}
?>