}
}
$this->cfg->setDebug($opts['debug']);
+ $this->cfg->setDryRun($opts['dryrun']);
return $res;
} catch (\Exception $exc) {
'default' => false,
)
);
+ $optParser->addOption(
+ 'dryrun',
+ array(
+ 'short_name' => '-n',
+ 'long_name' => '--dry-run',
+ 'description' => 'Do not send modifying HTTP request(s) to the server',
+ 'action' => 'StoreTrue',
+ 'default' => false,
+ )
+ );
Command_Connect::opts($optParser);
Command_Server::opts($optParser);
public $debug = false;
+ public $dryRun = false;
+
protected function getConfigFilePath()
{
if (!isset($_SERVER['HOME'])) {
return $key;
}
}
-
+
reset($this->hosts);
return key($this->hosts);
}
{
$this->debug = $debug;
}
+
+ public function setDryRun($dryRun)
+ {
+ $this->dryRun = $dryRun;
+ }
}
?>
$cp = new CurlPrinter();
$cp->show($this->req, $this->uploadsInfo, $this->dedicatedBody);
}
+
+ if ($this->cfg->dryRun && $this->req->getMethod() != 'GET') {
+ //do not run any modifying queries
+ //fake a successful response
+ $res = new \HTTP_Request2_Response('HTTP/1.1 200 OK', false);
+ $res->parseHeaderLine('Content-type: text/plain');
+ $res->appendBody('Fake --dry-run response');
+ return $res;
+ }
+
$res = $this->req->send();
if (intval($res->getStatus() / 100) != 2) {