Development

Changeset 1879

You must first sign up to be able to contribute.

Changeset 1879

Show
Ignore:
Timestamp:
08/30/06 14:46:24 (2 years ago)
Author:
fabien
Message:

added better messages for plugins management with symfony command line

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/data/tasks/sfPakePlugins.php

    r1867 r1879  
    4545  $packages = array($args[1]); 
    4646  pake_echo_action('plugin', 'installing plugin "'.$args[1].'"'); 
    47   $ret = _pear_run_command($config, 'install', array(), $packages); 
    48  
    49   _pear_restore_config($old_config); 
    50  
    51   if ($ret && !strpos($ret, 'not installed')) 
    52   { 
    53     throw new Exception($ret); 
     47  list($ret, $error) = _pear_run_command($config, 'install', array(), $packages); 
     48 
     49  _pear_restore_config($old_config); 
     50 
     51  if ($error)// && !strpos($ret, 'not installed')) 
     52  { 
     53    throw new Exception($error); 
    5454  } 
    5555} 
     
    6969  $packages = array($args[1]); 
    7070  pake_echo_action('plugin', 'upgrading plugin "'.$args[1].'"'); 
    71   $ret = _pear_run_command($config, 'upgrade', array(), $packages); 
    72  
    73   _pear_restore_config($old_config); 
    74  
    75   if ($ret && !strpos($ret, 'not installed')
    76   { 
    77     throw new Exception($ret); 
     71  list($ret, $error) = _pear_run_command($config, 'upgrade', array('loose' => true), $packages); 
     72 
     73  _pear_restore_config($old_config); 
     74 
     75  if ($error
     76  { 
     77    throw new Exception($error); 
    7878  } 
    7979} 
     
    9090  list($old_config, $config) = _pear_init($method); 
    9191 
    92   // install plugin 
     92  // uninstall plugin 
    9393  $packages = array($args[1]); 
    9494  pake_echo_action('plugin', 'uninstalling plugin "'.$args[1].'"'); 
    95   $ret = _pear_run_command($config, 'uninstall', array(), $packages); 
    96  
    97   _pear_restore_config($old_config); 
    98  
    99   if ($ret
    100   { 
    101     throw new Exception($ret); 
     95  list($ret, $error) = _pear_run_command($config, 'uninstall', array(), $packages); 
     96 
     97  _pear_restore_config($old_config); 
     98 
     99  if ($error
     100  { 
     101    throw new Exception($error); 
    102102  } 
    103103} 
     
    118118function _pear_run_command($config, $command, $opts, $params) 
    119119{ 
    120   ob_start(); 
     120  ob_start('_pear_echo_message', 2); 
    121121  $cmd = PEAR_Command::factory($command, $config); 
    122122  $ret = ob_get_clean(); 
     
    126126  } 
    127127 
    128   ob_start(); 
     128  ob_start('_pear_echo_message', 2); 
    129129  $ok   = $cmd->run($command, $opts, $params); 
    130130  $ret .= ob_get_clean(); 
    131131 
    132   return (PEAR::isError($ok) ? $ret.$ok->getMessage() : null); 
     132  $ret = trim($ret); 
     133 
     134  return PEAR::isError($ok) ? array($ret, $ok->getMessage()) : array($ret, null); 
     135
     136 
     137function _pear_echo_message($message) 
     138
     139  $t = ''; 
     140  foreach (explode("\n", $message) as $line) 
     141  { 
     142    if ($line = trim($line)) 
     143    { 
     144      $t .= pake_format_action('pear', $line); 
     145    } 
     146  } 
     147 
     148  return $t; 
    133149} 
    134150 
     
    224240  { 
    225241    // register our channel 
    226     $ret = _pear_run_command($config, 'channel-discover', array(), array('pear.symfony-project.com')); 
    227     if ($ret && !strpos($ret, 'already initialized')) 
    228     { 
    229       throw new Exception($ret); 
     242    list($ret, $error) = _pear_run_command($config, 'channel-discover', array(), array('pear.symfony-project.com')); 
     243    if ($error && !strpos($error, 'already initialized')) 
     244    { 
     245      throw new Exception($error); 
    230246    } 
    231247