Changeset 1794
- Timestamp:
- 08/24/06 07:37:10 (2 years ago)
- Files:
-
- tools/pake/trunk/lib/pake/pakeApp.class.php (modified) (9 diffs)
- tools/pake/trunk/lib/pake/pakeException.class.php (modified) (2 diffs)
- tools/pake/trunk/lib/pake/pakeFunction.php (modified) (10 diffs)
- tools/pake/trunk/lib/pake/pakeTask.class.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
tools/pake/trunk/lib/pake/pakeApp.class.php
r1791 r1794 233 233 break; 234 234 case 'version': 235 echo 'pake version '.pakeApp::VERSION."\n";235 echo sprintf('pake version %s', pakeColor::colorize(pakeApp::VERSION, 'INFO'))."\n"; 236 236 exit(); 237 237 default: … … 243 243 public function usage() 244 244 { 245 echo "pake [-f pakefile] {options} targets...\n Try pake -H for more information\n";245 echo "pake [-f pakefile] {options} targets...\n".pakeColor::colorize("Try pake -H for more information", 'INFO')."\n"; 246 246 } 247 247 … … 251 251 $this->usage(); 252 252 echo "\n"; 253 echo "available options ";253 echo "available options:"; 254 254 echo "\n"; 255 255 … … 262 262 $long .= '='.$match[1]; 263 263 } 264 printf(" %-20s (%s)\n", $long, $short);264 printf(" %-20s (%s)\n", pakeColor::colorize($long, 'INFO'), pakeColor::colorize($short, 'INFO')); 265 265 printf(" %s\n", $comment); 266 266 } … … 277 277 if ($w > $width) $width = $w; 278 278 } 279 280 echo "pake\n"; 279 $width += 12; 280 281 echo "available pake tasks:\n"; 281 282 282 283 // display tasks … … 293 294 { 294 295 $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.']' : '')); 296 297 } 297 298 } … … 299 300 if ($has_alias) 300 301 { 301 print("\n aliases:\n");302 print("\ntask aliases:\n"); 302 303 303 304 // display aliases … … 307 308 { 308 309 $mini_name = pakeTask::get_mini_task_name($name); 309 printf(' %-'.$width.'s = pake %s'."\n", pake Task::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.']' : '')); 310 311 } 311 312 } … … 368 369 $subsize = floor(($size - 3) / 2); 369 370 370 return substr($text, 0, $subsize). '...'.substr($text, -$subsize);371 return substr($text, 0, $subsize).pakeColor::colorize('...', 'INFO').substr($text, -$subsize); 371 372 } 372 373 tools/pake/trunk/lib/pake/pakeException.class.php
r1791 r1794 22 22 function render($e) 23 23 { 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"; 25 28 26 29 $pake = pakeApp::get_instance(); … … 28 31 if ($pake->get_trace()) 29 32 { 30 echo " \ntrace:\n";33 echo "exception trace:\n"; 31 34 32 35 $trace = $this->trace($e); tools/pake/trunk/lib/pake/pakeFunction.php
r1792 r1794 105 105 } 106 106 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); 110 110 } 111 111 … … 138 138 if ($options['override'] || !file_exists($target_file) || $most_recent) 139 139 { 140 if ($verbose) echo '>> file+ '.pakeApp::excerpt($target_file)."\n";140 pake_echo_action('file+', $target_file); 141 141 copy($origin_file, $target_file); 142 142 } … … 178 178 if (is_dir($file) && !is_link($file)) 179 179 { 180 if ($verbose) echo '>> dir- '.pakeApp::excerpt($file)."\n";180 pake_echo_action('dir-', $file); 181 181 182 182 rmdir($file); … … 184 184 else 185 185 { 186 if ($verbose) echo '>> file- '.pakeApp::excerpt($file)."\n";186 pake_echo_action('file-', $file); 187 187 188 188 unlink($file); … … 199 199 foreach ($files as $file) 200 200 { 201 if ($verbose) echo '>> file+ '.pakeApp::excerpt($file)."\n";201 pake_echo_action('file+', $file); 202 202 203 203 touch($file); … … 221 221 } 222 222 223 if ($verbose && $replaced) echo '>> tokens '.pakeApp::excerpt($target_dir.DIRECTORY_SEPARATOR.$file)."\n";223 pake_echo_action('tokens', $target_dir.DIRECTORY_SEPARATOR.$file); 224 224 225 225 file_put_contents($target_dir.DIRECTORY_SEPARATOR.$file, $content); … … 245 245 { 246 246 $verbose = pakeApp::get_instance()->get_verbose(); 247 if ($verbose) echo '>> symlink+ '.pakeApp::excerpt($target_dir)."\n";247 pake_echo_action('symlink+', $target_dir); 248 248 symlink($origin_dir, $target_dir); 249 249 } … … 261 261 foreach ($files as $file) 262 262 { 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); 264 264 chmod($target_dir.DIRECTORY_SEPARATOR.$file, $mode); 265 265 } … … 271 271 { 272 272 $verbose = pakeApp::get_instance()->get_verbose(); 273 if ($verbose) echo ">> exec $cmd\n";274 273 pake_echo_action('exec ', $cmd); 274 275 275 ob_start(); 276 276 passthru($cmd.' 2>&1', $return); … … 344 344 } 345 345 346 function 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 354 function pake_excerpt($text) 355 { 356 if (pakeApp::get_instance()->get_verbose()) 357 { 358 echo pakeApp::excerpt($text)."\n"; 359 } 360 } 361 362 function pake_echo($text) 363 { 364 if (pakeApp::get_instance()->get_verbose()) 365 { 366 echo $text."\n"; 367 } 368 } 369 346 370 // register our default exception handler 347 371 function pake_exception_default_handler($exception) tools/pake/trunk/lib/pake/pakeTask.class.php
r1791 r1794 154 154 if ($this->trace) 155 155 { 156 echo '>> invoke '.$this->name.' '.$this->format_trace_flags()."\n";156 pake_echo_action('invoke', $this->name.' '.$this->format_trace_flags()); 157 157 } 158 158 … … 187 187 if ($this->dryrun) 188 188 { 189 echo '>> execute (dry run) '.$this->name."\n";189 pake_echo_action('execute', '(dry run) '.$this->name); 190 190 return; 191 191 } … … 193 193 if ($this->trace) 194 194 { 195 echo '>> execute '.$this->name."\n";195 pake_echo_action('execute', $this->name); 196 196 } 197 197