static::addOptJson($cmd);
}
+ protected static function addOptHtml(\Console_CommandLine_Command $cmd)
+ {
+ $cmd->addOption(
+ 'html',
+ array(
+ 'short_name' => '-h',
+ 'long_name' => '--html',
+ 'description' => 'Text content is HTML',
+ 'action' => 'StoreTrue',
+ 'default' => false,
+ )
+ );
+ }
+
protected static function addOptJson(\Console_CommandLine_Command $cmd)
{
$cmd->addOption(
public static function opts(\Console_CommandLine $optParser)
{
$cmd = $optParser->addCommand('article');
- $cmd->addOption(
- 'html',
- array(
- 'short_name' => '-h',
- 'long_name' => '--html',
- 'description' => 'Text content is HTML',
- 'action' => 'StoreTrue',
- 'default' => false,
- )
- );
+ static::addOptHtml($cmd);
static::optsGeneric($cmd);
$cmd->addArgument(
'title',
$req = new Request($this->cfg->host, $this->cfg);
$req->setType('entry');
$req->addProperty('name', $cmdRes->args['title']);
- if ($cmdRes->options['html']) {
- $req->addProperty(
- 'content', ['html' => $cmdRes->args['text']]
- );
- } else {
- $req->addProperty('content', $cmdRes->args['text']);
- }
+ $req->addContent($cmdRes->args['text'], $cmdRes->options['html']);
$this->handleGenericOptions($cmdRes, $req);
$res = $req->send();
public static function opts(\Console_CommandLine $optParser)
{
$cmd = $optParser->addCommand('bookmark');
+ static::addOptHtml($cmd);
static::optsGeneric($cmd);
$cmd->addArgument(
'url',
$req->addProperty('bookmark-of', $url);
if ($cmdRes->args['text']) {
- $req->addProperty('content', $cmdRes->args['text']);
+ $req->addContent($cmdRes->args['text'], $cmdRes->options['html']);
}
public static function opts(\Console_CommandLine $optParser)
{
$cmd = $optParser->addCommand('note');
+ static::addOptHtml($cmd);
static::optsGeneric($cmd);
$cmd->addArgument(
'text',
{
$req = new Request($this->cfg->host, $this->cfg);
$req->setType('entry');
- $req->addProperty('content', $cmdRes->args['text']);
+ $req->addContent($cmdRes->args['text'], $cmdRes->options['html']);
$this->handleGenericOptions($cmdRes, $req);
$res = $req->send();
public static function opts(\Console_CommandLine $optParser)
{
$cmd = $optParser->addCommand('reply');
+ static::addOptHtml($cmd);
static::optsGeneric($cmd);
$cmd->addArgument(
'url',
'text',
[
'optional' => false,
- 'multiple' => true,
+ 'multiple' => false,
'description' => 'Reply text',
]
);
$req = new Request($this->cfg->host, $this->cfg);
$req->setType('entry');
- $req->addProperty('content', implode(' ', $cmdRes->args['text']));
$req->addProperty('in-reply-to', $url);
+ $req->addContent($cmdRes->args['text'], $cmdRes->options['html']);
$this->handleGenericOptions($cmdRes, $req);
$res = $req->send();
public static function opts(\Console_CommandLine $optParser)
{
$cmd = $optParser->addCommand('rsvp');
+ static::addOptHtml($cmd);
static::optsGeneric($cmd);
$cmd->addArgument(
'url',
$req->setType('h', 'entry');
$req->addProperty('in-reply-to', $url);
$req->addProperty('rsvp', $rsvp);
- if ($cmdRes->args['text'] != '') {
- $req->addProperty('content', $cmdRes->args['text']);
+ if ($cmdRes->args['text']) {
+ $req->addContent($cmdRes->args['text'], $cmdRes->options['html']);
}
$this->handleGenericOptions($cmdRes, $req);
return $this->req->addUpload($fieldName, $filename);
}
+ public function addContent($text, $isHtml)
+ {
+ if ($isHtml) {
+ $this->addProperty(
+ 'content', ['html' => $text]
+ );
+ } else {
+ $this->addProperty('content', $text);
+ }
+
+ }
+
/**
* Adds a micropub property to the request.
*