Author: ts
Date: Tue Mar  4 10:37:21 2008
New Revision: 7507

Log:
- Fixed issue #12625: console tools lacks documentation on targets.

Added:
    trunk/ConsoleTools/docs/tutorial_example_output_targets.php   (with props)
Modified:
    trunk/ConsoleTools/ChangeLog
    trunk/ConsoleTools/docs/tutorial.txt
    trunk/ConsoleTools/src/output.php

Modified: trunk/ConsoleTools/ChangeLog
==============================================================================
--- trunk/ConsoleTools/ChangeLog [iso-8859-1] (original)
+++ trunk/ConsoleTools/ChangeLog [iso-8859-1] Tue Mar  4 10:37:21 2008
@@ -12,6 +12,7 @@
   ezcConsoleMenuDialog::display() API doc.
 - Fixed issue #12628: Missing space in ezcConsoleInput::getHelp API doc.
 - Fixed issue #12626: Type "ta" in ezconsoleoutput documentation.
+- Fixed issue #12625: console tools lacks documentation on targets.
 
 1.3.2 - Monday 14 January 2008
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Modified: trunk/ConsoleTools/docs/tutorial.txt
==============================================================================
--- trunk/ConsoleTools/docs/tutorial.txt [iso-8859-1] (original)
+++ trunk/ConsoleTools/docs/tutorial.txt [iso-8859-1] Tue Mar  4 10:37:21 2008
@@ -141,6 +141,23 @@
 
 In our example, the call on line 23 would not print out text with the
 "verbosityLevel" option set to 3, but the call on line 25 would.
+
+The last example shows how to change the target of a format, which allows you
+to print text e.g. to STDERR.
+
+.. include:: tutorial_example_output_targets.php
+   :literal:
+
+The error message 'Unable to connect to database' will be printed in bold, with
+a red foreground color to STDOUT. The default target is
+ezcConsoleOutput::TARGET_OUTPUT, which prints to STDOUT and has standar output
+buffering in place. If you want to switch out the standard output bufferung,
+use ezcConsoleOutput::TARGET_STDOUT.
+
+Although this feature was originally not designed for that purpose, you can
+also use any other arbitrary PHP stream definition as a target. For example
+'file:///var/log/my.log' to get the messages redirected to a log file instead
+of displaying them.
 
 Mastering options and arguments
 -------------------------------

Added: trunk/ConsoleTools/docs/tutorial_example_output_targets.php
==============================================================================
--- trunk/ConsoleTools/docs/tutorial_example_output_targets.php (added)
+++ trunk/ConsoleTools/docs/tutorial_example_output_targets.php [iso-8859-1] 
Tue Mar  4 10:37:21 2008
@@ -1,0 +1,13 @@
+<?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' );
+
+?>

Propchange: trunk/ConsoleTools/docs/tutorial_example_output_targets.php
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: trunk/ConsoleTools/src/output.php
==============================================================================
--- trunk/ConsoleTools/src/output.php [iso-8859-1] (original)
+++ trunk/ConsoleTools/src/output.php [iso-8859-1] Tue Mar  4 10:37:21 2008
@@ -330,10 +330,17 @@
     /**
      * Print text to the console.
      *
-     * Output a string to the console. If $format parameter is omitted, 
-     * the default style is chosen. Style can either be a special style
-     * [EMAIL PROTECTED] ezcConsoleOutput::$options}, a style name 
-     * [EMAIL PROTECTED] ezcConsoleOutput$formats} or 'none' to print without 
any styling.
+     * Output a string to the console. If $format parameter is omitted, the
+     * default style is chosen. Style can either be a special style [EMAIL 
PROTECTED]
+     * ezcConsoleOutput::$options}, a style name [EMAIL PROTECTED]
+     * ezcConsoleOutput::$formats} or 'default' to print with the default
+     * styling.
+     *
+     * The $format parameter defines the name of a format. Formats are defined
+     * through the $formats proprty, which contains format definitions in form
+     * of [EMAIL PROTECTED] ezcConsoleOutputFormat} objects. The format 
influences the
+     * outer appearance of a message (e.g. color) as well as the target the
+     * message is printed to (e.g. STDERR).
      *
      * @throws ezcConsoleInvalidOutputTargetException
      *         If the given target ([EMAIL PROTECTED] ezcConsoleOutputFormat}) 
could not 
@@ -391,6 +398,12 @@
      * automatically appends a manual line break to the printed text. Besides
      * that, you can leave out the $text parameter of outputLine() to only
      * print a line break.
+     *
+     * The $format parameter defines the name of a format. Formats are defined
+     * through the $formats proprty, which contains format definitions in form
+     * of [EMAIL PROTECTED] ezcConsoleOutputFormat} objects. The format 
influences the
+     * outer appearance of a message (e.g. color) as well as the target the
+     * message is printed to (e.g. STDERR).
      * 
      * @param string $text        The text to print.
      * @param string $format      Format chosen for printing.


-- 
svn-components mailing list
svn-components@lists.ez.no
http://lists.ez.no/mailman/listinfo/svn-components

Reply via email to