svn: /pear2/sandbox/SimpleChannelServer/trunk/src/SimpleChannelServer/ CLI.php

From: Date: Wed, 14 Jul 2010 21:44:15 +0000
Subject: svn: /pear2/sandbox/SimpleChannelServer/trunk/src/SimpleChannelServer/ CLI.php
Groups: php.pear.cvs php.pear.core 
Request: Send a blank email to pear-core+get-9585@lists.php.net to get a copy of this message
saltybeagle Wed, 14 Jul 2010 21:44:15 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=301265 Log: Consistently retrieve the channel and throw an exception if it cannot be found. Bug #17594 Pyrus: SimpleChannelServer release bug. Bug: http://pear.php.net/bugs/17594 (unknown) Changed paths: U pear2/sandbox/SimpleChannelServer/trunk/src/SimpleChannelServer/CLI.php Modified: pear2/sandbox/SimpleChannelServer/trunk/src/SimpleChannelServer/CLI.php =================================================================== --- pear2/sandbox/SimpleChannelServer/trunk/src/SimpleChannelServer/CLI.php 2010-07-14 21:43:51 UTC (rev 301264) +++ pear2/sandbox/SimpleChannelServer/trunk/src/SimpleChannelServer/CLI.php 2010-07-14 21:44:15 UTC (rev 301265) @@ -25,14 +25,18 @@ */ public $scs; - public function __construct() + public function getSCS() { - $channel_file = getcwd() . '/channel.xml'; - $this->dir = getcwd(); - if (file_exists($channel_file)) { + if (!isset($this->scs)) { + $channel_file = getcwd() . '/channel.xml'; + $this->dir = getcwd(); + if (!file_exists($channel_file)) { + throw new Exception('No channel.xml file could be found! Create the channel, or change to the directory with the channel.xml.'); + } $this->channel = new \PEAR2\Pyrus\Channel(new \PEAR2\Pyrus\ChannelFile($channel_file)); $this->scs = new Main($this->channel, $this->dir); } + return $this->scs; } public function process() @@ -76,13 +80,13 @@ $args = array(); $args['package'] = $_SERVER['argv'][2]; $args['category'] = $_SERVER['argv'][3]; - $this->scs->categorize($args['package'], $args['category']); + $this->getSCS()->categorize($args['package'], $args['category']); echo "Added {$args['package']} to {$args['category']} \n"; } function pyrusCategorize($frontend, $args) { - $this->scs->categorize($args['package'], $args['category']); + $this->getSCS()->categorize($args['package'], $args['category']); echo "Added {$args['package']} to {$args['category']} \n"; } @@ -107,6 +111,7 @@ $args['description'] = (isset($_SERVER['argv'][3]))? $_SERVER['argv'][3]:$_SERVER['argv'][2]; + $this->getSCS(); $categories = new Categories($this->channel); $categories->create($args['category'], $args['description']); $category = new REST\Category($this->dir . '/rest', $this->channel, 'rest/', $categories); @@ -122,6 +127,7 @@ 'scs-create command first'); } + $this->getSCS(); $categories = new Categories($this->channel); $categories->create($args['category'], $args['description']); $category->savePackagesInfo($args['category']); @@ -139,10 +145,7 @@ function pyrusAddMaintainer($frontend, $args) { - if (!isset($this->channel)) { - throw new Exception('Unknown channel, run the ' . - 'scs-create command first'); - } + $this->getSCS(); $maintainer = new REST\Maintainer($this->dir . '/rest', $this->channel->name); if (isset($args['uri'])) { $uri = $args['uri']; @@ -169,10 +172,7 @@ function pyrusUpdate($frontend, $args) { - if (!isset($this->channel)) { - throw new Exception('Unknown channel, run the ' . - 'scs-create command first'); - } + $this->getSCS(); if (null === $frontend) { $maintainer = $args; } else { @@ -216,6 +216,7 @@ function pyrusRelease($frontend, $args) { + $this->getSCS(); if (null !== $frontend) { $chan = \PEAR2\Pyrus\Config::current()->default_channel; \PEAR2\Pyrus\Config::current()->default_channel = $this->channel->name;

« previous php.pear.core (#9585) next »