svn: /pear2/Pyrus/trunk/src/Pyrus/ScriptFrontend/ Commands.php

From: Date: Sat, 17 Jul 2010 13:35:02 +0000
Subject: svn: /pear2/Pyrus/trunk/src/Pyrus/ScriptFrontend/ Commands.php
Groups: php.pear.cvs php.pear.core 
Request: Send a blank email to pear-core+get-9596@lists.php.net to get a copy of this message
saltybeagle Sat, 17 Jul 2010 13:35:02 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=301348 Log: If an install command fails because of an undiscovered channel error, ask the user if they'd like to discover the channel and try the install again. Changed paths: U pear2/Pyrus/trunk/src/Pyrus/ScriptFrontend/Commands.php Modified: pear2/Pyrus/trunk/src/Pyrus/ScriptFrontend/Commands.php =================================================================== --- pear2/Pyrus/trunk/src/Pyrus/ScriptFrontend/Commands.php 2010-07-17 09:09:26 UTC (rev 301347) +++ pear2/Pyrus/trunk/src/Pyrus/ScriptFrontend/Commands.php 2010-07-17 13:35:02 UTC (rev 301348) @@ -497,6 +497,26 @@ echo $dep, ' depended on by ', implode(', ', array_keys($packages)), "\n"; } } catch (\Exception $e) { + + // If this is an undiscovered channel, handle it gracefully + if ($e instanceof \PEAR2\Pyrus\Package\Exception + && $e->getPrevious() instanceof \PEAR2\Pyrus\ChannelRegistry\Exception + && $e->getPrevious()->getPrevious() instanceof \PEAR2\Pyrus\ChannelRegistry\ParseException + && $e->getPrevious()->getPrevious()->why == 'channel' + && strpos($arg, '/') !== false) { + + $channel = strstr($arg, '/', true); + + echo "Sorry, the channel \"{$channel}\" is unknown.\n"; + + if ('yes' === $this->ask('Do you want to add this channel and continue the install?', array('yes', 'no'), 'yes')) { + $this->channelDiscover(array('channel' => $channel)); + $this->install($args, $options); + return; + } + echo "Ok. I understand.\n"; + } + $this->exceptionHandler($e); exit -1; }

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