Exemplo n.º 1
0
 /**
  * Displays report or generates its files
  *
  * @param PHP_ConfigReport_Report $report Report
  * @return void
  */
 public function render(PHP_ConfigReport_Report $report)
 {
     $consoleOutput = new ezcConsoleOutput();
     $consoleOutput->formats->extensionName->style = array('bold');
     $consoleOutput->formats->columnTitle->style = array('bold');
     $consoleOutput->formats->error->bgcolor = 'red';
     $consoleOutput->formats->warning->bgcolor = 'yellow';
     $consoleOutput->outputLine('PHP version: ' . $report->getPhpVersion());
     $consoleOutput->outputLine('Environment: ' . $report->getEnvironment());
     $noIssue = true;
     foreach ($report->getSections() as $section) {
         if ($section->hasIssues()) {
             $noIssue = false;
             $consoleOutput->outputLine();
             $consoleOutput->outputLine($section->getExtensionName(), 'extensionName');
             $table = new ezcConsoleTable($consoleOutput, $this->_width);
             $table[0]->format = 'columnTitle';
             $table[0][0]->content = 'Directive';
             $table[0][1]->content = 'Level';
             $table[0][2]->content = 'Type';
             $table[0][3]->content = 'Value';
             $table[0][4]->content = 'Suggested value';
             $table[0][5]->content = 'Comments';
             foreach ($section->getIssues() as $index => $issue) {
                 $table[$index + 1]->format = $issue->getLevel();
                 $directiveName = $issue->getDirectiveName();
                 if (is_array($directiveName)) {
                     $directiveName = implode(' / ', $directiveName);
                 }
                 $table[$index + 1][0]->content = $directiveName;
                 $table[$index + 1][1]->content = $issue->getLevel();
                 $table[$index + 1][2]->content = $issue->getType();
                 $directiveActualValue = $issue->getDirectiveActualValue();
                 if (is_array($directiveActualValue)) {
                     $directiveActualValue = implode(' / ', $directiveActualValue);
                 }
                 $table[$index + 1][3]->content = $directiveActualValue;
                 $directiveSuggestedValue = $issue->getDirectiveSuggestedValue();
                 if (is_array($directiveSuggestedValue)) {
                     $directiveSuggestedValue = implode(' / ', $directiveSuggestedValue);
                 }
                 $table[$index + 1][4]->content = $directiveSuggestedValue;
                 $table[$index + 1][5]->content = $issue->getComments();
             }
             $table->outputTable();
             $consoleOutput->outputLine();
         }
     }
     if ($noIssue) {
         $consoleOutput->outputLine('No issue found.');
         $consoleOutput->outputLine();
     }
 }
Exemplo n.º 2
0
 /**
  * Generate table output
  *
  * @param VcsStats_Table $table Table
  * @return void
  */
 public function renderTable(VcsStats_Report_Element_Table $table)
 {
     $result = '';
     $output = new ezcConsoleOutput();
     $output->formats->title->style = array('bold');
     $alignments = array('center' => ezcConsoleTable::ALIGN_CENTER, 'left' => ezcConsoleTable::ALIGN_LEFT, 'right' => ezcConsoleTable::ALIGN_RIGHT);
     $consoleTable = new ezcConsoleTable($output, 78);
     // Display header
     $consoleTable[0]->align = ezcConsoleTable::ALIGN_CENTER;
     foreach ($table->getColumns() as $column) {
         $consoleTable[0][]->content = $column->getTitle();
     }
     // Display values
     foreach ($table->getRows() as $i => $row) {
         $j = 0;
         foreach ($row as $code => $value) {
             $alignment = $table->getColumn($code)->getAlignment();
             $consoleTable[$i + 1][$j]->align = $alignments[$alignment];
             $consoleTable[$i + 1][$j]->content = $value;
             $j++;
         }
     }
     ob_start();
     $output->outputLine();
     $output->outputLine($table->getTitle(), 'title');
     $consoleTable->outputTable();
     $output->outputLine();
     $output->outputLine();
     $result .= ob_get_clean();
     echo $result;
 }
Exemplo n.º 3
0
 /**
  * Prints the message of an occured error and exits the program.
  * This method is used to print an error message, as soon as an error
  * occurs end quit the program with return code -1. Optionally, the
  * method will trigger the help text to be printed after the error message.
  * 
  * @param string $message The error message to print
  * @param bool $printHelp Whether to print the help after the error msg.
  */
 private function raiseError($message, $printHelp = false)
 {
     $this->output->outputLine($message, 'error');
     $this->output->outputLine();
     if ($printHelp === true) {
         $this->output->outputText($this->input->getHelpText(ezcPersistentObjectSchemaGenerator::PROGRAM_DESCRIPTION), "help");
     }
     exit(-1);
 }
Exemplo n.º 4
0
 /**
  * Prints the message of an occured error and exits the program.
  * This method is used to print an error message, as soon as an error
  * occurs end quit the program with return code -1. Optionally, the
  * method will trigger the help text to be printed after the error message.
  *
  * @param string $message The error message to print
  * @param bool $printHelp Whether to print the help after the error msg.
  */
 private function raiseError($message, $printHelp = false)
 {
     $this->output->outputLine($message, 'error');
     $this->output->outputLine();
     if ($printHelp === true) {
         $this->output->outputText($this->input->getHelpText(self::PROGRAM_DESCRIPTION), "help");
     }
     exit(-1);
 }
Exemplo n.º 5
0
 public function testProgressMonitor4()
 {
     $out = new ezcConsoleOutput();
     $out->formats->tag->color = 'red';
     $out->formats->percent->color = 'blue';
     $out->formats->percent->style = array('bold');
     $out->formats->data->color = 'green';
     $status = new ezcConsoleProgressMonitor($out, 7, array('formatString' => $out->formatText('%2$10s', 'tag') . ' ' . $out->formatText('%1$6.2f%%', 'percent') . ' ' . $out->formatText('%3$s', 'data')));
     ob_start();
     for ($i = 0; $i < 7; $i++) {
         $status->addEntry($this->stati[$i][0], $this->stati[$i][1]);
     }
     $res = ob_get_contents();
     ob_end_clean();
     // To prepare test files use this:
     // file_put_contents( dirname( __FILE__ ) . '/data/' . ( ezcBaseFeatures::os() === "Windows" ? "windows/" : "posix/" ) . 'testProgressMonitor4.dat', $res );
     $this->assertEquals(file_get_contents(dirname(__FILE__) . '/data/' . (ezcBaseFeatures::os() === "Windows" ? "windows/" : "posix/") . 'testProgressMonitor4.dat'), $res, "Formated statusbar not generated correctly.");
 }
Exemplo n.º 6
0
 /**
  * Add a status to the status bar.
  * Adds a new status to the bar which is printed immediately. If the
  * cursor is currently not at the beginning of a line, it will move to
  * the next line.
  *
  * @param bool $status Print successChar on true, failureChar on false.
  * @return void
  */
 public function add($status)
 {
     if (is_bool($status) === false) {
         trigger_error('Unknown status ' . var_export($status, true) . '.', E_USER_WARNING);
         $status = (bool) $status;
     }
     switch ($status) {
         case true:
             $this->outputHandler->outputText($this->properties['options']['successChar'], 'success');
             break;
         case false:
             $this->outputHandler->outputText($this->properties['options']['failureChar'], 'failure');
             break;
     }
     $this->counter[$status]++;
 }
Exemplo n.º 7
0
 public function testRestorePosFailure()
 {
     if (ezcBaseFeatures::os() === 'Windows') {
         $this->markTestSkipped("Does not work on Windows");
     }
     $output = new ezcConsoleOutput();
     try {
         $output->restorePos();
     } catch (ezcConsoleNoPositionStoredException $e) {
         return;
     }
     $this->fail("Exception not thrown on restore position without stored position.");
 }
Exemplo n.º 8
0
 * @package ConsoleTools
 * @version //autogen//
 * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
 */
require_once 'Base/src/base.php';
/**
 * Autoload ezc classes 
 * 
 * @param string $className 
 */
function __autoload($className)
{
    ezcBase::autoload($className);
}
// Create the output handler
$out = new ezcConsoleOutput();
// Set the verbosity to level 10
$out->options->verbosityLevel = 10;
// Enable auto wrapping of lines after 40 characters
$out->options->autobreak = 40;
// Set the color of the default output format to green
$out->formats->default->color = 'green';
// Set the color of the output format named 'success' to white
$out->formats->success->color = 'white';
// Set the style of the output format named 'success' to bold
$out->formats->success->style = array('bold');
// Set the color of the output format named 'failure' to red
$out->formats->failure->color = 'red';
// Set the style of the output format named 'failure' to bold
$out->formats->failure->style = array('bold');
// Set the background color of the output format named 'failure' to blue
Exemplo n.º 9
0
 public function testProgress9()
 {
     $out = new ezcConsoleOutput();
     $formatString = '' . $out->formatText('Actual progress', 'success') . ': <' . $out->formatText('%bar%', 'failure') . '> ' . $out->formatText('%fraction%', 'success');
     $this->commonProgressbarTest(__FUNCTION__, 1073, 123, array('barChar' => '123', 'emptyChar' => '987', 'progressChar' => '---', 'width' => 97, 'formatString' => $formatString, 'fractionFormat' => '%o'));
 }
Exemplo n.º 10
0
 /**
  * Generate a single physical row.
  * This method generates the string for a single physical table row.
  * 
  * @param array(int=>string) $cells Cells of the row.
  * @param array(int=>int) $colWidth Calculated columns widths.
  * @param ezcConsoleTableRow $row   The row to generate.
  * @return string The row.
  */
 private function generateRow($cells, $colWidth, $row)
 {
     $rowData = '';
     for ($cell = 0; $cell < count($colWidth); $cell++) {
         $align = $this->determineAlign($row, $cell);
         $format = $this->determineFormat($row, $cell);
         $borderFormat = $this->determineBorderFormat($row);
         $data = isset($cells[$cell]) ? $cells[$cell] : '';
         $rowData .= $this->outputHandler->formatText($this->properties['options']->lineHorizontal, $borderFormat);
         $rowData .= $this->properties['options']->colPadding;
         $rowData .= $this->outputHandler->formatText(str_pad($data, $colWidth[$cell], ' ', $align), $format);
         $rowData .= $this->properties['options']->colPadding;
     }
     $rowData .= $this->outputHandler->formatText($this->properties['options']->lineHorizontal, $row->borderFormat);
     return $rowData;
 }
require 'autoload.php';

$cli = eZCLI::instance();
$script = eZScript::instance( array( 'description' => ( "Fixes eZImageAliasHandler bug (http://issues.ez.no/15155)" ),
                                     'use-session' => false,
                                     'use-modules' => true,
                                     'use-extensions' => true ) );

$script->startup();

$options = $script->getOptions( "[n]",
                                "",
                                array( 'n' => 'Do not wait the 10 safety seconds before starting' ) );
$script->initialize();

$output = new ezcConsoleOutput();
$output->formats->error->style = array( 'bold' );
$output->formats->error->color = 'red';

if ( !isset( $options['n'] ) )
{
    $output->outputLine( 'This script will delete images that look orphan' );
    $output->outputLine( 'Press ctrl-c in the next 10 seconds to prevent the script from starting...' );
    sleep( 10 );
}

try
{
    $output->outputLine( 'Looking for obsolete image files...' );

    // Fetch all image files in ezimagefile table
Exemplo n.º 12
0
 * @package ConsoleTools
 * @version //autogen//
 * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved.
 * @license http://ez.no/licenses/new_bsd New BSD License
 */
require_once 'Base/src/base.php';
/**
 * Autoload ezc classes 
 * 
 * @param string $className 
 */
function __autoload($className)
{
    ezcBase::autoload($className);
}
$out = new ezcConsoleOutput();
// Create a progress monitor
$status = new ezcConsoleProgressMonitor($out, 7);
// Perform actions
$i = 0;
while ($i++ < 7) {
    // Do whatever you want to indicate progress for
    usleep(mt_rand(20000, 2000000));
    // Advance the statusbar by one step
    $status->addEntry('ACTION', "Performed action #{$i}.");
}
$out->outputLine();
/*
OUTPUT:
    14.3% ACTION Performed action #1.
    28.6% ACTION Performed action #2.
Exemplo n.º 13
0
 /**
  * Overloaded __set() method to gain read-only access to properties.
  * It also performs checks on setting others.
  *
  * @throws ezcBasePropertyNotFoundException
  *         If the setting you try to access does not exists
  * @throws ezcBaseValueException
  *         If trying to set an invalid value for a setting.
  * 
  * @param string $propertyName Name of the attrinbute to access.
  * @param string $val The value to set.
  * @ignore
  */
 public function __set($propertyName, $val)
 {
     if (!isset($this->properties[$propertyName])) {
         throw new ezcBasePropertyNotFoundException($propertyName);
     }
     // Extry handling of multi styles
     if ($propertyName === 'style') {
         if (!is_array($val)) {
             $val = array($val);
         }
         foreach ($val as $style) {
             if (!ezcConsoleOutput::isValidFormatCode($propertyName, $style)) {
                 throw new ezcBaseValueException($propertyName, $style, 'valid ezcConsoleOutput format code');
             }
         }
         $this->properties['style'] = $val;
         return;
     }
     // Continue normal handling
     if (($propertyName === "color" || $propertyName === "bgcolor") && !ezcConsoleOutput::isValidFormatCode($propertyName, $val)) {
         throw new ezcBaseValueException($propertyName, $val, 'valid ezcConsoleOutput format code');
     }
     $this->properties[$propertyName] = $val;
 }
Exemplo n.º 14
0
 /**
  * Draw the progress bar.
  * Prints the progress-bar to the screen. If start() has not been called 
  * yet, the current line is used for {@link ezcConsolProgressbar::start()}.
  *
  * @return void
  */
 public function output()
 {
     if ($this->options->minVerbosity > $this->output->options->verbosityLevel || $this->options->maxVerbosity !== false && $this->options->maxVerbosity < $this->output->options->verbosityLevel) {
         // Do not print progress bar if verbosity level is lower than it's
         // output objects value.
         return;
     }
     if ($this->started === false) {
         $this->start();
     }
     $this->output->restorePos();
     if (ezcBaseFeatures::os() === "Windows") {
         echo str_repeat("", $this->options->width);
     }
     $this->generateValues();
     echo $this->insertValues();
 }
Exemplo n.º 15
0
<?php

/**
 * Analyses a FOF song and gets tracks & difficulties
 */
include dirname(__FILE__) . '/lib/autoload.php';
$input = new ezcConsoleInput();
$dryRunOption = $input->registerOption(new ezcConsoleOption('d', 'dry-run', ezcConsoleInput::TYPE_NONE, false));
$quietOption = $input->registerOption(new ezcConsoleOption('q', 'quiet', ezcConsoleInput::TYPE_NONE, false));
$helpOption = $input->registerOption(new ezcConsoleOption('h', 'help'));
$verboseOption = $input->registerOption(new ezcConsoleOption('v', 'verbose', ezcConsoleInput::TYPE_NONE, false));
$input->argumentDefinition = new ezcConsoleArguments();
$input->argumentDefinition[0] = new ezcConsoleArgument("artist");
$input->argumentDefinition[0]->mandatory = true;
$input->argumentDefinition[0]->shorthelp = "The artist to search for";
$output = new ezcConsoleOutput();
$output->formats->info->color = 'blue';
$output->formats->error->color = 'red';
$output->formats->error->style = array('bold');
$output->formats->fatal->color = 'red';
$output->formats->fatal->style = array('bold', 'underlined');
$output->formats->fatal->bgcolor = 'black';
try {
    $input->process();
} catch (ezcConsoleArgumentMandatoryViolationException $e) {
    if ($helpOption->value === true) {
        $output->outputText($input->getHelpText("Auto-link by artist name"));
        exit;
    } else {
        $output->outputLine("No arguments given", "fatal");
        $output->outputText($input->getHelpText("Auto-link by artist name"));
<?php

require_once 'tutorial_autoload.php';
$output = new ezcConsoleOutput();
$output->formats->info->color = 'blue';
$output->outputText('Test text in color blue', 'info');
Exemplo n.º 17
0
 /**
  * Returns the code for a given formating option of a given type.
  *
  * $type is the type of formating ('color', 'bgcolor' or 'style'), $key the
  * name of the format to lookup. Returns the numeric code for the requested
  * format or 0 if format or type do not exist.
  * 
  * @see ezcConsoleOutput::isValidFormatCode()
  * 
  * @param string $type Formatting type.
  * @param string $key  Format option name.
  * @return int The code representation.
  */
 protected function getFormatCode($type, $key)
 {
     if (!ezcConsoleOutput::isValidFormatCode($type, $key)) {
         return 0;
     }
     return ezcConsoleOutput::${$type}[$key];
 }
<?php

require_once 'tutorial_autoload.php';
$output = new ezcConsoleOutput();
$output->formats->error->color = 'red';
$output->formats->error->style = array('bold');
$output->formats->error->target = ezcConsoleOutput::TARGET_STDERR;
$output->outputLine('Unable to connect to database', 'error');
Exemplo n.º 19
0
 /**
  * Print a status entry.
  * Prints a new status entry to the console and updates the internal counter.
  *
  * @param string $tag  The tag to print (second argument in the 
  *                     formatString).
  * @param string $data The data to be printed in the status entry (third 
  *                     argument in the format string).
  * @return void
  */
 public function addEntry($tag, $data)
 {
     $this->counter++;
     $percentage = $this->counter / $this->max * 100;
     $this->outputHandler->outputLine(sprintf($this->options['formatString'], $percentage, $tag, $data));
 }
Exemplo n.º 20
0
 /**
  * Displays version informations
  *
  * @return void
  */
 public static function displayVersion()
 {
     self::$consoleOutput->outputLine('vcsstats 0.1-dev by Jean-Marc Fontaine', 'version');
 }
Exemplo n.º 21
0
<?php

class ezcConsoleOutput
{
    protected static $color = array('gray' => 30);
    public static function isValidFormatCode($type, $key)
    {
        return isset(self::${$type}[$key]);
    }
}
var_dump(ezcConsoleOutput::isValidFormatCode('color', 'gray'));
Exemplo n.º 22
0
 /**
  * Finishes progress output for class search phase.
  *
  * Also inserts some extra newlines to make the output clearer.
  *
  * @return void
  */
 public function finishPhase2()
 {
     $this->tokenizerProgress->finish();
     $this->output->outputLine();
     $this->output->outputLine();
 }
<?php

require_once 'tutorial_autoload.php';
$output = new ezcConsoleOutput();
$output->formats->info->color = 'blue';
$output->formats->info->style = array('bold');
$output->setOptions(array('autobreak' => 78, 'verbosityLevel' => 3));
$output->outputLine('This is a very very long info text. It has so much information in ' . 'it, that it will definitly not fit into 1 line. Therefore, ' . 'ezcConsoleOutput will automatically wrap the line for us.', 'info');
$output->outputLine();
$output->outputLine('This verbose information will currently not be displayed.', 'info', 10);
$output->outputLine('But this verbose information will be displayed.', 'info', 2);
Exemplo n.º 24
0
 /**
  * Returns the given $text formatted with $format.
  *
  * In case $useFormats is set to false in the output handler, the text is 
  * returned as given, without any formatting.
  * 
  * @param string $text 
  * @param string $format 
  * @return string
  */
 private function formatText($text, $format)
 {
     if ($this->outputHandler->options->useFormats) {
         return $this->outputHandler->formatText($text, $format);
     } else {
         return $text;
     }
 }
Exemplo n.º 25
0
 /**
  * Returns the instance of the class
  *
  * @param boolean $isCliMode
  * @return CjwNewsletterLog
  */
 public static function getInstance($isCliMode = false)
 {
     try {
         if (is_null(self::$instance)) {
             self::$instance = new self($isCliMode);
             ezcBaseInit::fetchConfig('cjwNewsletterInitLog', self::$instance);
         }
         return self::$instance;
     } catch (ezcBaseFilePermissionException $e) {
         eZDebug::writeError($e->getMessage(), 'CjwNewsletterLog::getInstance()');
         if ($isCliMode) {
             $output = new ezcConsoleOutput();
             $output->formats->error->color = 'red';
             $output->formats->error->style = array('bold');
             $output->outputLine($e->getMessage(), 'error');
             exit;
         }
     }
 }
Exemplo n.º 26
0
 /**
  * Clears view cache for imported content objects.
  * ObjectIDs are stored in 'ezpending_actions' table, with {@link SQLIContent::ACTION_CLEAR_CACHE} action
  */
 public static function viewCacheClear()
 {
     $db = eZDB::instance();
     $isCli = isset($_SERVER['argv']);
     $output = null;
     $progressBar = null;
     $i = 0;
     $conds = array('action' => SQLIContent::ACTION_CLEAR_CACHE);
     $limit = array('offset' => 0, 'length' => 50);
     $count = (int) eZPersistentObject::count(eZPendingActions::definition(), $conds);
     if ($isCli && $count > 0) {
         // Progress bar implementation
         $output = new ezcConsoleOutput();
         $output->outputLine('Starting to clear view cache for imported objects...');
         $progressBarOptions = array('emptyChar' => ' ', 'barChar' => '=');
         $progressBar = new ezcConsoleProgressbar($output, $count, $progressBarOptions);
         $progressBar->start();
     }
     /*
      * To avoid fatal errors due to memory exhaustion, pending actions are fetched by packets
      */
     do {
         $aObjectsToClear = eZPendingActions::fetchObjectList(eZPendingActions::definition(), null, $conds, null, $limit);
         $jMax = count($aObjectsToClear);
         if ($jMax > 0) {
             for ($j = 0; $j < $jMax; ++$j) {
                 if ($isCli) {
                     $progressBar->advance();
                 }
                 $db->begin();
                 eZContentCacheManager::clearContentCacheIfNeeded((int) $aObjectsToClear[$j]->attribute('param'));
                 $aObjectsToClear[$j]->remove();
                 $db->commit();
                 $i++;
             }
         }
         unset($aObjectsToClear);
         eZContentObject::clearCache();
         if (eZINI::instance('site.ini')->variable('ContentSettings', 'StaticCache') == 'enabled') {
             $optionArray = array('iniFile' => 'site.ini', 'iniSection' => 'ContentSettings', 'iniVariable' => 'StaticCacheHandler');
             $options = new ezpExtensionOptions($optionArray);
             $staticCacheHandler = eZExtension::getHandlerClass($options);
             $staticCacheHandler::executeActions();
         }
     } while ($i < $count);
     if ($isCli && $count > 0) {
         $progressBar->finish();
         $output->outputLine();
     }
 }
Exemplo n.º 27
0
 public function testRestorePosFailure()
 {
     $output = new ezcConsoleOutput();
     try {
         $output->restorePos();
     } catch (ezcConsoleNoPositionStoredException $e) {
         return;
     }
     $this->fail("Exception not thrown on restore position without stored position.");
 }
Exemplo n.º 28
0
 * @package ConsoleTools
 * @version //autogen//
 * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved.
 * @license http://ez.no/licenses/new_bsd New BSD License
 */
require_once 'Base/src/base.php';
/**
 * Autoload ezc classes 
 * 
 * @param string $className 
 */
function __autoload($className)
{
    ezcBase::autoload($className);
}
$out = new ezcConsoleOutput();
$out->formats->red->color = "red";
// Create progress bar itself
$progress = new ezcConsoleProgressbar($out, 100, array('step' => 5));
$progress->options->emptyChar = '-';
$progress->options->progressChar = $out->formatText('>', "red");
$progress->options->formatString = "Uploading file </tmp/foobar.tar.bz2>: %act%/%max% kb [%bar%]";
// Perform actions
$i = 0;
while ($i++ < 20) {
    // Do whatever you want to indicate progress for
    usleep(mt_rand(20000, 2000000));
    // Advance the progressbar by one step ( uploading 5k per run )
    $progress->advance();
}
// Finish progress bar and jump to next line.
$helpOption->isHelpOption = true;

$sourceFileOption = $input->registerOption( new ezcConsoleOption( 's', 'source-file' ) );
$sourceFileOption->shorthelp = "File containing class to generate tests from";
$sourceFileOption->mandatory = true;
$sourceFileOption->type = ezcConsoleInput::TYPE_STRING;

$destinationFileOption = $input->registerOption( new ezcConsoleOption( 'd', 'dest-file' ) );
$destinationFileOption->shorthelp = "File to write the tests to";
$destinationFileOption->mandatory = true;
$destinationFileOption->type = ezcConsoleInput::TYPE_STRING;


// Set ouput formatting
// ---------------------------------------------------------------------------
$out = new ezcConsoleOutput();
$out->formats->count->style = array( 'bold' );
$out->formats->source->color = 'green';
$out->formats->dest->color = 'yellow';


// Process options
// ---------------------------------------------------------------------------
try
{
    $input->process();
}
catch ( ezcConsoleOptionException $e )
{
    die( $e->getMessage() );
}
Exemplo n.º 30
0
 * @package ConsoleTools
 * @version 1.6.1
 * @copyright Copyright (C) 2005-2010 eZ Systems AS. All rights reserved.
 * @license http://ez.no/licenses/new_bsd New BSD License
 */
require_once 'Base/src/base.php';
/**
 * Autoload ezc classes 
 * 
 * @param string $className 
 */
function __autoload($className)
{
    ezcBase::autoload($className);
}
$out = new ezcConsoleOutput();
// Create status bar itself
$status = new ezcConsoleStatusbar($out);
// Perform actions
$i = 0;
while ($i++ < 20) {
    // Do whatever you want to indicate progress for
    usleep(mt_rand(20000, 2000000));
    // Indicate success or failure
    $status->add((bool) mt_rand(0, 1));
}
$out->outputLine();
// Print statistics
$out->outputLine($status->getSuccessCount() . ' operations succeeded, ' . $status->getFailureCount() . ' failed.');
/*
OUTPUT: