cvs: peardoc / global.ent /en/package console.xml /en/package/console console-progressbar.xml

From: Date: Tue, 14 Nov 2006 12:51:29 +0000
Subject: cvs: peardoc / global.ent /en/package console.xml /en/package/console console-progressbar.xml
Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-8801@lists.php.net to get a copy of this message
cweiske Tue Nov 14 12:51:29 2006 UTC Added files: /peardoc/en/package/console console-progressbar.xml Modified files: /peardoc global.ent /peardoc/en/package console.xml Log: Console_Progressbar documentation http://cvs.php.net/viewvc.cgi/peardoc/global.ent?r1=1.67&r2=1.68&diff_format=u Index: peardoc/global.ent diff -u peardoc/global.ent:1.67 peardoc/global.ent:1.68 --- peardoc/global.ent:1.67 Tue Nov 14 10:49:23 2006 +++ peardoc/global.ent Tue Nov 14 12:51:28 2006 @@ -1,6 +1,6 @@ <!-- -*- SGML -*- - $Id: global.ent,v 1.67 2006/11/14 10:49:23 cweiske Exp $ + $Id: global.ent,v 1.68 2006/11/14 12:51:28 cweiske Exp $ Contains global "macros" for all the XML documents. @@ -220,3 +220,4 @@ <!-- For links to the API documentation generated by phpdocumentor --> <!ENTITY phpdocbase.html-page2 "http://pear.php.net/package/HTML_Page2/docs/latest/HTML_Page2/HTML_Page2.html#method"> +<!ENTITY phpdocbase.console-progressbar "http://pear.php.net/package/Console_ProgressBar/docs/latest/Console_ProgressBar/Console_ProgressBar.html#method"> http://cvs.php.net/viewvc.cgi/peardoc/en/package/console.xml?r1=1.6&r2=1.7&diff_format=u Index: peardoc/en/package/console.xml diff -u peardoc/en/package/console.xml:1.6 peardoc/en/package/console.xml:1.7 --- peardoc/en/package/console.xml:1.6 Fri Feb 17 16:04:31 2006 +++ peardoc/en/package/console.xml Tue Nov 14 12:51:28 2006 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.6 $ --> +<!-- $Revision: 1.7 $ --> <chapter id="package.console"> <title>Console</title> @@ -11,6 +11,7 @@ &blankpagehack; &package.console.console-getopt; + &package.console.console-progressbar; &package.console.console-table; </chapter> http://cvs.php.net/viewvc.cgi/peardoc/en/package/console/console-progressbar.xml?view=markup&rev=1.1 Index: peardoc/en/package/console/console-progressbar.xml +++ peardoc/en/package/console/console-progressbar.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <sect1 id="package.console.console-progressbar"> <title>Console_Progressbar</title> <para> <classname>Console_Progressbar</classname> displays a customizable progress bar in the console/terminal. </para> <example> <title>Some progress bar examples</title> <screen><![CDATA[ This will display a very simple bar: ===================================================== ]]></screen> <para></para> <screen><![CDATA[ A more complicated bar, showing current status in numbers as well: * 3/7 [==========================>-------------------------------------] 42.86% ]]></screen> <para></para> <screen><![CDATA[ Showing elapsed time, and using ANSI codes: - 109/345 [========>------------------] 31.59% Elapsed Time: 00:03.94 ]]></screen> <para></para> <screen><![CDATA[ Showing an estimate for the remaining time: - 105/345 [============>-------------------------------] 30.43% ETA: 00:11.52 ]]></screen> </example> <orderedlist> <title>Things to setup</title> <listitem> <para> <literal>require_once "Console/Progressbar.php"</literal> </para> </listitem> <listitem> <para> Create a new instance of <classname>Console_Progressbar</classname>. </para> </listitem> <listitem> <para> Call <ulink url="&phpdocbase.console-progressbar;update"><function>update</function></ulink> whenever some progress has been made. </para> </listitem> <listitem> <para> (optional) <ulink url="&phpdocbase.console-progressbar;erase"><function>erase</function></ulink>. after you're finished. </para> </listitem> </orderedlist> <example> <title>Simple progressbar example</title> <programlisting role="php"><![CDATA[ <?php require_once 'Console/ProgressBar.php'; $bar = new Console_ProgressBar('[%bar%] %percent%', '=>', ' ', 80, 7); //do some processing here for ($i = 0; $i <= 7; $i++) { $bar->update($i); sleep(1); } echo "\n"; ?> ]]></programlisting> <para></para> <screen><![CDATA[ [=======================================> ] 57.14% ]]></screen> </example> <sect2> <title>Creating the bar</title> <para> In the example we create the progress bar instance with five parameters: The <parameter>format string</parameter>, <parameter>bar string</parameter>, <parameter>empty string</parameter>, <parameter>console width</parameter> and the <parameter>target number</parameter>. </para> <para> The first parameter, <parameter>format string</parameter>, defines the layout of the whole progress bar. It may contain any character and has some variables that get replaced: <itemizedlist> <listitem> <para> <literal>%bar%</literal> is the actual progress bar. </para> </listitem> <listitem> <para> <literal>%current%</literal> is the current value set via <ulink url="&phpdocbase.console-progressbar;update"><function>update</function></ulink>. </para> </listitem> <listitem> <para> <literal>%max%</literal> is replaced with the maximum value set by the constructor (target number). </para> </listitem> <listitem> <para> <literal>%fraction%</literal> - the same as <literal>%current%/%max%</literal>. </para> </listitem> <listitem> <para> <literal>%percent%</literal> - status in percent. </para> </listitem> <listitem> <para> <literal>%elapsed%</literal> - elapsed time. </para> </listitem> <listitem> <para> <literal>%estimate%</literal> - an estimation of how long the progress will take. </para> </listitem> </itemizedlist> </para> <para> The second argument is the string that is going to fill the progress bar. In the above example, the string "=>" was used. If the string you pass is too short (like "=>" in this example), the leftmost character is used to pad it to the needed size. If the string you pass is too long, excessive characters are stripped from the left. </para> <para> The third argument is the string that fills the "empty" space in the progress bar. In the above example, that would be "-". If the string you pass is too short (like "-" in this example), the rightmost character is used to pad it to the needed size. If the string you pass is too short, excessive characters are stripped from the right. </para> <para> The fourth argument specifies the width of the display. A normal console/terminal is 80 chars, so pass 80 here. Currently there is no method to determine the current width of a terminal. </para> <para> The fifth argument is the target number of the progress bar. For example, if you wanted to display a progress bar for a download of a file that is 115 KB big, you would pass 115 here. </para> </sect2> <sect2> <title>Updating and finishing</title> <para> After setting up the progress bar, you can start doing the real work - up- or downloading files, calculating something etc. Whenever you did a step forward, call <ulink url="&phpdocbase.console-progressbar;update"><function>update</function></ulink> with the current step number. </para> <para> When you're finished, you may want to remove the progress bar from screen - use <ulink url="&phpdocbase.console-progressbar;erase"><function>erase</function></ulink> for this. </para> </sect2> </sect1> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->

« previous php.pear.doc (#8801) next »