// }}}
+ // {{{ _displayValidationResults()
+
+ function _displayValidationResults($err, $warn, $strict = false)
+ {
+ foreach ($err as $e) {
+ $this->ui->displayLine("Error: $e");
+ }
+ foreach ($warn as $w) {
+ $this->ui->displayLine("Warning: $w");
+ }
+ $this->ui->displayLine(sprintf('Validation: %d error(s), %d warning(s)',
+ sizeof($err), sizeof($warn)));
+ if ($strict && sizeof($err) > 0) {
+ $this->ui->displayLine("Fix these errors and try again.");
+ return false;
+ }
+ return true;
+ }
+
+ // }}}
// {{{ getCommands()
/**
return array('package',
'package-info',
'package-list',
- 'package-validate');
+ 'package-validate',
+ 'cvstag');
}
// }}}
+ // {{{ getOptions()
+ function getOptions()
+ {
+ return array('Z', 'n' /*, 'f', 'd', 'q', 'Q'*/);
+ }
+
+ // }}}
// {{{ getHelp()
function getHelp($command)
case 'package-validate':
return array('<package.(tgz|tar|xml)>',
'Verifies a package or description file');
+ case 'cvstag':
+ return array('<package.xml>',
+ 'Runs "cvs tag" on files contained in a release');
}
}
// }}}
-
// {{{ run()
/**
$packager->debug = $this->config->get('verbose');
$err = $warn = array();
$packager->validatePackageInfo($pkginfofile, $err, $warn);
- foreach ($err as $e) {
- $this->ui->displayLine("Error: $e");
- }
- foreach ($warn as $w) {
- $this->ui->displayLine("Warning: $w");
- }
- $this->ui->displayLine(sprintf('%d error(s), %d warning(s)',
- sizeof($err), sizeof($warn)));
- if (sizeof($err) > 0) {
- $this->ui->displayLine("Fix these errors and try again.");
+ if (!$this->_displayValidationResults($err, $warn, true)) {
break;
}
- $result = $packager->Package($pkginfofile);
+ $compress = empty($options['Z']) ? true : false;
+ $result = $packager->Package($pkginfofile, $compress);
$output = ob_get_contents();
ob_end_clean();
$lines = explode("\n", $output);
$this->ui->displayLine($line);
}
if (PEAR::isError($result)) {
- $this->ui->displayLine("Package failed!");
- } else {
- $this->ui->displayLine("Package ok.");
+ $this->ui->displayLine("Package failed: ".$result->getMessage());
}
break;
}
}
$obj = new PEAR_Common;
$info = null;
- $validate_result = $obj->validatePackageInfo($info, $err, $warn);
if (file_exists($params[0])) {
$fp = fopen($params[0], "r");
$test = fread($fp, 5);
if (PEAR::isError($info)) {
return $this->raiseError($info);
}
- foreach ($err as $e) {
- $this->ui->displayLine("Error: $e");
+ $obj->validatePackageInfo($info, $err, $warn);
+ $this->_displayValidationResults($err, $warn);
+ break;
+ }
+
+ // }}}
+ // {{{ cvstag
+
+ case 'cvstag': {
+ if (sizeof($params) < 1) {
+ $help = $this->getHelp($command);
+ return $this->raiseError("$command: missing parameter: $help[0]");
+ }
+ $obj = new PEAR_Common;
+ $info = $obj->infoFromDescriptionFile($params[0]);
+ if (PEAR::isError($info)) {
+ return $this->raiseError($info);
}
- foreach ($warn as $w) {
- $this->ui->displayLine("Warning: $w");
+ $err = $warn = array();
+ $obj->validatePackageInfo($info, $err, $warn);
+ if (!$this->_displayValidationResults($err, $warn, true)) {
+ break;
+ }
+ $version = $info['version'];
+ $cvsversion = preg_replace('/[^a-z0-9]/i', '_', $version);
+ $cvstag = "RELEASE_$cvsversion";
+ $files = array_keys($info['filelist']);
+ $command = "cvs";
+ /* until the getopt bug is fixed, these won't work:
+ if (isset($options['q'])) {
+ $command .= ' -q';
+ }
+ if (isset($options['Q'])) {
+ $command .= ' -Q';
+ }
+ */
+ $command .= ' tag';
+ if (isset($options['f'])) {
+ $command .= ' -f';
+ }
+ /* neither will this one:
+ if (isset($options['d'])) {
+ $command .= ' -d';
+ }
+ */
+ $command .= ' ' . $cvstag . ' ' . escapeshellarg($params[0]);
+ foreach ($files as $file) {
+ $command .= ' ' . escapeshellarg($file);
+ }
+ $this->ui->displayLine("+ $command");
+ if (empty($options['n'])) {
+ $fp = popen($command, "r");
+ while ($line = fgets($fp, 1024)) {
+ $this->ui->displayLine(rtrim($line));
+ }
+ pclose($fp);
}
- $this->ui->displayLine(sprintf('%d error(s), %d warning(s)',
- sizeof($err), sizeof($warn)));
break;
}
* @access public
*/
var $type = 'CLI';
+ var $lp = ''; // line prefix
var $omode = 'plain';
var $params = array();
// }}}
- // For now, all the display functions print a "| " at the
- // beginning of the line. This is just a temporary thing, it
- // is for discovering commands that use print instead of
- // the UI layer.
-
// {{{ displayLine(text)
function displayLine($text)
{
- print "| $text\n";
+ print "$this->lp$text\n";
}
// }}}
function displayHeading($title)
{
- print "| ".$this->bold($title)."\n";
- print "| ".str_repeat("=", strlen($title))."\n";
+ print $this->lp.$this->bold($title)."\n";
+ print $this->lp.str_repeat("=", strlen($title))."\n";
}
// }}}
if ($type == 'password') {
system('stty -echo');
}
- print "| $prompt ";
+ print "$this->lp$prompt ";
if ($default) {
print "[$default] ";
}
{
static $positives = array('y', 'yes', 'on', '1');
static $negatives = array('n', 'no', 'off', '0');
- print "| $prompt [$default] : ";
+ print "$this->lp$prompt [$default] : ";
$fp = fopen("php://stdin", "r");
$line = fgets($fp, 2048);
fclose($fp);