Development

Changeset 1794

You must first sign up to be able to contribute.

Changeset 1794

Show
Ignore:
Timestamp:
08/24/06 07:37:10 (2 years ago)
Author:
fabien
Message:

added color to default actions in pake

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • tools/pake/trunk/lib/pake/pakeApp.class.php

    r1791 r1794  
    233233        break; 
    234234      case 'version': 
    235         echo 'pake version '.pakeApp::VERSION."\n"; 
     235        echo sprintf('pake version %s', pakeColor::colorize(pakeApp::VERSION, 'INFO'))."\n"; 
    236236        exit(); 
    237237      default: 
     
    243243  public function usage() 
    244244  { 
    245     echo "pake [-f pakefile] {options} targets...\nTry pake -H for more information\n"; 
     245    echo "pake [-f pakefile] {options} targets...\n".pakeColor::colorize("Try pake -H for more information", 'INFO')."\n"; 
    246246  } 
    247247 
     
    251251    $this->usage(); 
    252252    echo "\n"; 
    253     echo "available options"; 
     253    echo "available options:"; 
    254254    echo "\n"; 
    255255 
     
    262262          $long .= '='.$match[1]; 
    263263      } 
    264       printf("  %-20s (%s)\n", $long, $short); 
     264      printf("  %-20s (%s)\n", pakeColor::colorize($long, 'INFO'), pakeColor::colorize($short, 'INFO')); 
    265265      printf("      %s\n", $comment); 
    266266    } 
     
    277277      if ($w > $width) $width = $w; 
    278278    } 
    279  
    280     echo "pake\n"; 
     279    $width += 12; 
     280 
     281    echo "available pake tasks:\n"; 
    281282 
    282283    // display tasks 
     
    293294      { 
    294295        $mini_name = pakeTask::get_mini_task_name($name); 
    295         printf('  %-'.$width.'s > %s'."\n", $mini_name, $task->get_comment().($mini_name != $name ? ' ['.$name.']' : '')); 
     296        printf('  %-'.$width.'s > %s'."\n", pakeColor::colorize($mini_name, 'INFO'), $task->get_comment().($mini_name != $name ? ' ['.$name.']' : '')); 
    296297      } 
    297298    } 
     
    299300    if ($has_alias) 
    300301    { 
    301       print("\naliases:\n"); 
     302      print("\ntask aliases:\n"); 
    302303 
    303304      // display aliases 
     
    307308        { 
    308309          $mini_name = pakeTask::get_mini_task_name($name); 
    309           printf('  %-'.$width.'s = pake %s'."\n", pakeTask::get_mini_task_name($name), $task->get_alias().($mini_name != $name ? ' ['.$name.']' : '')); 
     310          printf('  %-'.$width.'s = pake %s'."\n", pakeColor::colorize(pakeTask::get_mini_task_name($name), 'INFO'), $task->get_alias().($mini_name != $name ? ' ['.$name.']' : '')); 
    310311        } 
    311312      } 
     
    368369    $subsize = floor(($size - 3) / 2); 
    369370 
    370     return substr($text, 0, $subsize).'...'.substr($text, -$subsize); 
     371    return substr($text, 0, $subsize).pakeColor::colorize('...', 'INFO').substr($text, -$subsize); 
    371372  } 
    372373 
  • tools/pake/trunk/lib/pake/pakeException.class.php

    r1791 r1794  
    2222  function render($e) 
    2323  { 
    24     echo pakeColor::colorize('  ['.get_class($e).'] '.$e->getMessage()."  \n", 'ERROR'); 
     24    $message = '  ['.get_class($e).'] '.$e->getMessage().'  '; 
     25    echo "\n".pakeColor::colorize(str_repeat(' ', strlen($message))."\n", 'ERROR'); 
     26    echo pakeColor::colorize($message."\n", 'ERROR'); 
     27    echo pakeColor::colorize(str_repeat(' ', strlen($message))."\n", 'ERROR')."\n"; 
    2528 
    2629    $pake = pakeApp::get_instance(); 
     
    2831    if ($pake->get_trace()) 
    2932    { 
    30       echo "\ntrace:\n"; 
     33      echo "exception trace:\n"; 
    3134 
    3235      $trace = $this->trace($e); 
  • tools/pake/trunk/lib/pake/pakeFunction.php

    r1792 r1794  
    105105  } 
    106106 
    107   if ($verbose) echo '>> dir+      '.pakeApp::excerpt($path)."\n"
    108  
    109   return mkdir($path, $mode, true); 
     107  pake_echo_action('dir+', $path)
     108 
     109  return @mkdir($path, $mode, true); 
    110110} 
    111111 
     
    138138  if ($options['override'] || !file_exists($target_file) || $most_recent) 
    139139  { 
    140     if ($verbose) echo '>> file+     '.pakeApp::excerpt($target_file)."\n"
     140    pake_echo_action('file+', $target_file)
    141141    copy($origin_file, $target_file); 
    142142  } 
     
    178178    if (is_dir($file) && !is_link($file)) 
    179179    { 
    180       if ($verbose) echo '>> dir-      '.pakeApp::excerpt($file)."\n"
     180      pake_echo_action('dir-', $file)
    181181 
    182182      rmdir($file); 
     
    184184    else 
    185185    { 
    186       if ($verbose) echo '>> file-     '.pakeApp::excerpt($file)."\n"
     186      pake_echo_action('file-', $file)
    187187 
    188188      unlink($file); 
     
    199199  foreach ($files as $file) 
    200200  { 
    201     if ($verbose) echo '>> file+     '.pakeApp::excerpt($file)."\n"
     201    pake_echo_action('file+', $file)
    202202 
    203203    touch($file); 
     
    221221    } 
    222222 
    223     if ($verbose && $replaced) echo '>> tokens    '.pakeApp::excerpt($target_dir.DIRECTORY_SEPARATOR.$file)."\n"
     223    pake_echo_action('tokens', $target_dir.DIRECTORY_SEPARATOR.$file)
    224224 
    225225    file_put_contents($target_dir.DIRECTORY_SEPARATOR.$file, $content); 
     
    245245  { 
    246246    $verbose = pakeApp::get_instance()->get_verbose(); 
    247     if ($verbose) echo '>> symlink+  '.pakeApp::excerpt($target_dir)."\n"
     247    pake_echo_action('symlink+', $target_dir)
    248248    symlink($origin_dir, $target_dir); 
    249249  } 
     
    261261  foreach ($files as $file) 
    262262  { 
    263     if ($verbose) printf('>> chmod %o '.pakeApp::excerpt($target_dir.DIRECTORY_SEPARATOR.$file)."\n", $mode); 
     263    pake_echo_action(sprintf('chmod %o', $mode), $target_dir.DIRECTORY_SEPARATOR.$file); 
    264264    chmod($target_dir.DIRECTORY_SEPARATOR.$file, $mode); 
    265265  } 
     
    271271{ 
    272272  $verbose = pakeApp::get_instance()->get_verbose(); 
    273   if ($verbose) echo ">> exec      $cmd\n"
    274    
     273  pake_echo_action('exec ', $cmd)
     274 
    275275  ob_start(); 
    276276  passthru($cmd.' 2>&1', $return); 
     
    344344} 
    345345 
     346function pake_echo_action($section, $text) 
     347{ 
     348  if (pakeApp::get_instance()->get_verbose()) 
     349  { 
     350    echo sprintf('>> %-20s %s', pakeColor::colorize($section, 'INFO'), pakeApp::excerpt($text))."\n"; 
     351  } 
     352} 
     353 
     354function pake_excerpt($text) 
     355{ 
     356  if (pakeApp::get_instance()->get_verbose()) 
     357  { 
     358    echo pakeApp::excerpt($text)."\n"; 
     359  } 
     360} 
     361 
     362function pake_echo($text) 
     363{ 
     364  if (pakeApp::get_instance()->get_verbose()) 
     365  { 
     366    echo $text."\n"; 
     367  } 
     368} 
     369 
    346370// register our default exception handler 
    347371function pake_exception_default_handler($exception) 
  • tools/pake/trunk/lib/pake/pakeTask.class.php

    r1791 r1794  
    154154    if ($this->trace) 
    155155    { 
    156       echo '>> invoke '.$this->name.' '.$this->format_trace_flags()."\n"
     156      pake_echo_action('invoke', $this->name.' '.$this->format_trace_flags())
    157157    } 
    158158 
     
    187187    if ($this->dryrun) 
    188188    { 
    189       echo '>> execute (dry run) '.$this->name."\n"
     189      pake_echo_action('execute', '(dry run) '.$this->name)
    190190      return; 
    191191    } 
     
    193193    if ($this->trace) 
    194194    { 
    195       echo '>> execute '.$this->name."\n"
     195      pake_echo_action('execute', $this->name)
    196196    } 
    197197