Development

Changeset 1791

You must first sign up to be able to contribute.

Changeset 1791

Show
Ignore:
Timestamp:
08/23/06 23:17:06 (2 years ago)
Author:
fabien
Message:

pake: update email address + added pakeColor class + better handling of exceptions

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • tools/pake/trunk/bin/pake.php

    r1765 r1791  
    1313include_once('pake/pakeFunction.php'); 
    1414 
     15// register our default exception handler 
     16function pake_exception_default_handler($exception) 
     17{ 
     18  $e = new pakeException(); 
     19  $e->render($exception); 
     20} 
     21set_exception_handler('pake_exception_default_handler'); 
     22 
    1523if (basename(__FILE__) == basename($_SERVER['SCRIPT_NAME'])) 
    1624{ 
    1725  $pake = pakeApp::get_instance(); 
    18   try 
    19   { 
    20     $pake->run(); 
    21   } 
    22   catch (pakeException $e) 
    23   { 
    24     echo "ERROR: pake - ".$e->getMessage()."\n"; 
    25   } 
     26  $pake->run(); 
    2627} 
  • tools/pake/trunk/lib/pake/pakeApp.class.php

    r1765 r1791  
    33/** 
    44 * @package    pake 
    5  * @author     Fabien Potencier <fabien.potencier@gmail.com> 
    6  * @copyright  2004-2005 Fabien Potencier <fabien.potencier@gmail.com> 
     5 * @author     Fabien Potencier <fabien.potencier@symfony-project.com> 
     6 * @copyright  2004-2005 Fabien Potencier <fabien.potencier@symfony-project.com> 
    77 * @license    see the LICENSE file included in the distribution 
    88 * @version    SVN: $Id$ 
     
    1616 * 
    1717 * @package    pake 
    18  * @author     Fabien Potencier <fabien.potencier@gmail.com> 
    19  * @copyright  2004-2005 Fabien Potencier <fabien.potencier@gmail.com> 
     18 * @author     Fabien Potencier <fabien.potencier@symfony-project.com> 
     19 * @copyright  2004-2005 Fabien Potencier <fabien.potencier@symfony-project.com> 
    2020 * @license    see the LICENSE file included in the distribution 
    2121 * @version    SVN: $Id$ 
  • tools/pake/trunk/lib/pake/pakeException.class.php

    r1765 r1791  
    33/* 
    44 * This file is part of the pake package. 
    5  * (c) 2004, 2005 Fabien Potencier <fabien.potencier@gmail.com> 
     5 * (c) 2004, 2005 Fabien Potencier <fabien.potencier@symfony-project.com> 
    66 *  
    77 * For the full copyright and license information, please view the LICENSE 
     
    1515 * 
    1616 * @package    pake 
    17  * @author     Fabien Potencier <fabien.potencier@gmail.com> 
     17 * @author     Fabien Potencier <fabien.potencier@symfony-project.com> 
    1818 * @version    SVN: $Id$ 
    1919 */ 
    2020class pakeException extends Exception 
    2121{ 
    22   /** 
    23    * Class constructor. 
    24    * 
    25    * @param string The error message. 
    26    * @param int    The error code. 
    27    */ 
    28   public function __construct ($message = null, $code = 0) 
     22  function render($e) 
    2923  { 
    30     parent::__construct($message, $code); 
     24    echo pakeColor::colorize('  ['.get_class($e).'] '.$e->getMessage()."  \n", 'ERROR'); 
     25 
     26    $pake = pakeApp::get_instance(); 
     27 
     28    if ($pake->get_trace()) 
     29    { 
     30      echo "\ntrace:\n"; 
     31 
     32      $trace = $this->trace($e); 
     33      for ($i = 0, $count = count($trace); $i < $count; $i++) 
     34      { 
     35        $class = (isset($trace[$i]['class']) ? $trace[$i]['class'] : ''); 
     36        $type = (isset($trace[$i]['type']) ? $trace[$i]['type'] : ''); 
     37        $function = $trace[$i]['function']; 
     38        $file = isset($trace[$i]['file']) ? $trace[$i]['file'] : 'n/a'; 
     39        $line = isset($trace[$i]['line']) ? $trace[$i]['line'] : 'n/a'; 
     40 
     41        echo sprintf(" %s%s%s at %s:%s.\n", $class, $type, $function, pakeColor::colorize($file, 'INFO'), pakeColor::colorize($line, 'INFO')); 
     42      } 
     43    } 
     44 
     45    echo "\n"; 
     46  } 
     47 
     48  function trace($exception) 
     49  { 
     50    // exception related properties 
     51    $trace = $exception->getTrace(); 
     52    array_unshift($trace, array( 
     53      'function' => '', 
     54      'file'     => ($exception->getFile() != null) ? $exception->getFile() : 'n/a', 
     55      'line'     => ($exception->getLine() != null) ? $exception->getLine() : 'n/a', 
     56      'args'     => array(), 
     57    )); 
     58 
     59    return $trace; 
    3160  } 
    3261} 
  • tools/pake/trunk/lib/pake/pakeFileTask.class.php

    r1765 r1791  
    33/** 
    44 * @package    pake 
    5  * @author     Fabien Potencier <fabien.potencier@gmail.com> 
    6  * @copyright  2004-2005 Fabien Potencier <fabien.potencier@gmail.com> 
     5 * @author     Fabien Potencier <fabien.potencier@symfony-project.com> 
     6 * @copyright  2004-2005 Fabien Potencier <fabien.potencier@symfony-project.com> 
    77 * @license    see the LICENSE file included in the distribution 
    88 * @version    SVN: $Id$ 
     
    1616 * 
    1717 * @package    pake 
    18  * @author     Fabien Potencier <fabien.potencier@gmail.com> 
    19  * @copyright  2004-2005 Fabien Potencier <fabien.potencier@gmail.com> 
     18 * @author     Fabien Potencier <fabien.potencier@symfony-project.com> 
     19 * @copyright  2004-2005 Fabien Potencier <fabien.potencier@symfony-project.com> 
    2020 * @license    see the LICENSE file included in the distribution 
    2121 * @version    SVN: $Id$ 
  • tools/pake/trunk/lib/pake/pakeFinder.class.php

    r1783 r1791  
    33/** 
    44 * @package    pake 
    5  * @author     Fabien Potencier <fabien.potencier@gmail.com> 
    6  * @copyright  2004-2005 Fabien Potencier <fabien.potencier@gmail.com> 
     5 * @author     Fabien Potencier <fabien.potencier@symfony-project.com> 
     6 * @copyright  2004-2005 Fabien Potencier <fabien.potencier@symfony-project.com> 
    77 * @license    see the LICENSE file included in the distribution 
    88 * @version    SVN: $Id$ 
     
    3232 * 
    3333 * @package    pake 
    34  * @author     Fabien Potencier <fabien.potencier@gmail.com> 
    35  * @copyright  2004-2005 Fabien Potencier <fabien.potencier@gmail.com> 
     34 * @author     Fabien Potencier <fabien.potencier@symfony-project.com> 
     35 * @copyright  2004-2005 Fabien Potencier <fabien.potencier@symfony-project.com> 
    3636 * @license    see the LICENSE file included in the distribution 
    3737 * @version    SVN: $Id$ 
  • tools/pake/trunk/lib/pake/pakeFunction.php

    r1784 r1791  
    11<?php 
     2 
     3/** 
     4 * @package    pake 
     5 * @author     Fabien Potencier <fabien.potencier@symfony-project.com> 
     6 * @copyright  2004-2005 Fabien Potencier <fabien.potencier@symfony-project.com> 
     7 * @license    see the LICENSE file included in the distribution 
     8 * @version    SVN: $Id$ 
     9 */ 
    210 
    311require_once 'pake/pakeException.class.php'; 
     
    715require_once 'pake/pakeTask.class.php'; 
    816require_once 'pake/pakeFileTask.class.php'; 
     17require_once 'pake/pakeColor.class.php'; 
    918require_once 'pake/pakeApp.class.php'; 
    1019 
  • tools/pake/trunk/lib/pake/pakeGetopt.class.php

    r1765 r1791  
    33/** 
    44 * @package    pake 
    5  * @author     Fabien Potencier <fabien.potencier@gmail.com> 
    6  * @copyright  2004-2005 Fabien Potencier <fabien.potencier@gmail.com> 
     5 * @author     Fabien Potencier <fabien.potencier@symfony-project.com> 
     6 * @copyright  2004-2005 Fabien Potencier <fabien.potencier@symfony-project.com> 
    77 * @license    see the LICENSE file included in the distribution 
    88 * @version    SVN: $Id$ 
     
    1919 * 
    2020 * @package    pake 
    21  * @author     Fabien Potencier <fabien.potencier@gmail.com> 
    22  * @copyright  2004-2005 Fabien Potencier <fabien.potencier@gmail.com> 
     21 * @author     Fabien Potencier <fabien.potencier@symfony-project.com> 
     22 * @copyright  2004-2005 Fabien Potencier <fabien.potencier@symfony-project.com> 
    2323 * @license    see the LICENSE file included in the distribution 
    2424 * @version    SVN: $Id$ 
  • tools/pake/trunk/lib/pake/pakeGlobToRegex.class.php

    r1765 r1791  
    33/** 
    44 * @package    pake 
    5  * @author     Fabien Potencier <fabien.potencier@gmail.com> php port 
     5 * @author     Fabien Potencier <fabien.potencier@symfony-project.com> php port 
    66 * @author     Richard Clamp <richardc@unixbeard.net> perl version 
    7  * @copyright  2004-2005 Fabien Potencier <fabien.potencier@gmail.com> 
     7 * @copyright  2004-2005 Fabien Potencier <fabien.potencier@symfony-project.com> 
    88 * @copyright  2002 Richard Clamp <richardc@unixbeard.net> 
    99 * @license    see the LICENSE file included in the distribution 
     
    3535 * 
    3636 * @package    pake 
    37  * @author     Fabien Potencier <fabien.potencier@gmail.com> php port 
     37 * @author     Fabien Potencier <fabien.potencier@symfony-project.com> php port 
    3838 * @author     Richard Clamp <richardc@unixbeard.net> perl version 
    39  * @copyright  2004-2005 Fabien Potencier <fabien.potencier@gmail.com> 
     39 * @copyright  2004-2005 Fabien Potencier <fabien.potencier@symfony-project.com> 
    4040 * @copyright  2002 Richard Clamp <richardc@unixbeard.net> 
    4141 * @license    see the LICENSE file included in the distribution 
  • tools/pake/trunk/lib/pake/pakeNumberCompare.class.php

    r1765 r1791  
    33/** 
    44 * @package    pake 
    5  * @author     Fabien Potencier <fabien.potencier@gmail.com> php port 
     5 * @author     Fabien Potencier <fabien.potencier@symfony-project.com> php port 
    66 * @author     Richard Clamp <richardc@unixbeard.net> perl version 
    7  * @copyright  2004-2005 Fabien Potencier <fabien.potencier@gmail.com> 
     7 * @copyright  2004-2005 Fabien Potencier <fabien.potencier@symfony-project.com> 
    88 * @copyright  2002 Richard Clamp <richardc@unixbeard.net> 
    99 * @license    see the LICENSE file included in the distribution 
     
    3434 * 
    3535 * @package    pake 
    36  * @author     Fabien Potencier <fabien.potencier@gmail.com> php port 
     36 * @author     Fabien Potencier <fabien.potencier@symfony-project.com> php port 
    3737 * @author     Richard Clamp <richardc@unixbeard.net> perl version 
    38  * @copyright  2004-2005 Fabien Potencier <fabien.potencier@gmail.com> 
     38 * @copyright  2004-2005 Fabien Potencier <fabien.potencier@symfony-project.com> 
    3939 * @copyright  2002 Richard Clamp <richardc@unixbeard.net> 
    4040 * @see        http://physics.nist.gov/cuu/Units/binary.html 
  • tools/pake/trunk/lib/pake/pakeTask.class.php

    r1765 r1791  
    33/** 
    44 * @package    pake 
    5  * @author     Fabien Potencier <fabien.potencier@gmail.com> 
    6  * @copyright  2004-2005 Fabien Potencier <fabien.potencier@gmail.com> 
     5 * @author     Fabien Potencier <fabien.potencier@symfony-project.com> 
     6 * @copyright  2004-2005 Fabien Potencier <fabien.potencier@symfony-project.com> 
    77 * @license    see the LICENSE file included in the distribution 
    88 * @version    SVN: $Id$ 
     
    1616 * 
    1717 * @package    pake 
    18  * @author     Fabien Potencier <fabien.potencier@gmail.com> 
    19  * @copyright  2004-2005 Fabien Potencier <fabien.potencier@gmail.com> 
     18 * @author     Fabien Potencier <fabien.potencier@symfony-project.com> 
     19 * @copyright  2004-2005 Fabien Potencier <fabien.potencier@symfony-project.com> 
    2020 * @license    see the LICENSE file included in the distribution 
    2121 * @version    SVN: $Id$ 
  • tools/pake/trunk/lib/pake/pakeYaml.class.php

    r1765 r1791  
    11<?php 
     2 
     3/** 
     4 * @package    pake 
     5 * @author     Fabien Potencier <fabien.potencier@symfony-project.com> 
     6 * @copyright  2004-2005 Fabien Potencier <fabien.potencier@symfony-project.com> 
     7 * @license    see the LICENSE file included in the distribution 
     8 * @version    SVN: $Id$ 
     9 */ 
     10 
    211  class pakeYaml 
    312  { 
  • tools/pake/trunk/lib/pake/tasks/pakePearTask.class.php

    r1765 r1791  
    11<?php 
     2 
     3/** 
     4 * @package    pake 
     5 * @author     Fabien Potencier <fabien.potencier@symfony-project.com> 
     6 * @copyright  2004-2005 Fabien Potencier <fabien.potencier@symfony-project.com> 
     7 * @license    see the LICENSE file included in the distribution 
     8 * @version    SVN: $Id$ 
     9 */ 
    210 
    311class pakePearTask 
  • tools/pake/trunk/lib/pake/tasks/pakePhingTask.class.php

    r1773 r1791  
    11<?php 
     2 
     3/** 
     4 * @package    pake 
     5 * @author     Fabien Potencier <fabien.potencier@symfony-project.com> 
     6 * @copyright  2004-2005 Fabien Potencier <fabien.potencier@symfony-project.com> 
     7 * @license    see the LICENSE file included in the distribution 
     8 * @version    SVN: $Id$ 
     9 */ 
    210 
    311include_once 'phing/Phing.php'; 
  • tools/pake/trunk/lib/pake/tasks/pakeSimpletestTask.class.php

    r1766 r1791  
    11<?php 
     2 
     3/** 
     4 * @package    pake 
     5 * @author     Fabien Potencier <fabien.potencier@symfony-project.com> 
     6 * @copyright  2004-2005 Fabien Potencier <fabien.potencier@symfony-project.com> 
     7 * @license    see the LICENSE file included in the distribution 
     8 * @version    SVN: $Id$ 
     9 */ 
    210 
    311class pakeSimpletestTask 
  • tools/pake/trunk/pakefile.php

    r1765 r1791  
    1010pake_desc('release a new pake version'); 
    1111pake_task('release'); 
     12 
     13pake_task('foo'); 
     14 
     15function run_foo($task, $args) 
     16{ 
     17  throw new Exception('test'); 
     18} 
    1219 
    1320/* tasks */