cvs: peardoc /en/package/php/php-compatinfo command-line.xml

From: Date: Sat, 19 Jul 2008 12:46:28 +0000
Subject: cvs: peardoc /en/package/php/php-compatinfo command-line.xml
Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-11014@lists.php.net to get a copy of this message
farell Sat Jul 19 12:46:28 2008 UTC Added files: /peardoc/en/package/php/php-compatinfo command-line.xml Log: new version of command line parser interface

http://cvs.php.net/viewvc.cgi/peardoc/en/package/php/php-compatinfo/command-line.xml?view=markup&rev=1.1 Index: peardoc/en/package/php/php-compatinfo/command-line.xml +++ peardoc/en/package/php/php-compatinfo/command-line.xml <!-- $Revision: 1.1 $ --> <refentry id="package.php.php-compatinfo.command-line"> <refnamediv> <refname>The Command-Line Parser</refname> <refpurpose>parsing data source with CLI</refpurpose> </refnamediv> <para> The <emphasis role="bold">Command-Line Parser</emphasis> can be invoked through the <command>pci</command> command. </para> <para> Let's take a look at the command-line parser switches: </para> <para> <screen> Usage: pci [options] -d --dir (optional)value Parse DIR to get its compatibility info () -f --file (optional)value Parse FILE to get its compatibility info () -s --string (optional)value Parse STRING to get its compatibility info () -v --verbose (optional)value Set the verbose level (1) -n --no-recurse Do not recursively parse files when using --dir -if --ignore-files (optional)value Data file name which contains a list of file to ignore (files.txt) -id --ignore-dirs (optional)value Data file name which contains a list of directory to ignore (dirs.txt) -in --ignore-functions (optional)value Data file name which contains a list of php function to ignore (functions.txt) -ic --ignore-constants (optional)value Data file name which contains a list of php constant to ignore (constants.txt) -ie --ignore-extensions (optional)value Data file name which contains a list of php extension to ignore (extensions.txt) -iv --ignore-versions values(optional) PHP versions - functions to exclude when parsing source code (5.0.0) -inm --ignore-functions-match (optional)value Data file name which contains a list of php function pattern to ignore (functions-match.txt) -iem --ignore-extensions-match (optional)value Data file name which contains a list of php extension pattern to ignore (extensions-match.txt) -icm --ignore-constants-match (optional)value Data file name which contains a list of php constant pattern to ignore (constants-match.txt) -fe --file-ext (optional)value A comma separated list of file extensions to parse (only valid if parsing a directory) (php, php4, inc, phtml) -r --report (optional)value Print either "xml" or "csv" report (text) -o --output-level (optional)value Print Path/File + Version with additional data (31) -t --tab (optional)value Columns width (29,12,20) -p --progress (optional)value Show a wait message [text] or a progress bar [bar] (bar) -S --summarize Print only summary when parsing directory -V --version Print version information -h --help Show this help </screen> </para> <para> <variablelist> <varlistentry> <term> <parameter>-d</parameter> | <parameter>--dir</parameter> </term> <listitem> <para> <cmdsynopsis> <command>pci</command> <arg>-d <replaceable>directory</replaceable></arg> </cmdsynopsis> </para> <para> Runs the parser with all default options, and try to analyze content of files into directory identified by switch -d or --dir </para> </listitem> </varlistentry> <varlistentry> <term> <parameter>-f</parameter> | <parameter>--file</parameter> </term> <listitem> <para> <cmdsynopsis> <command>pci</command> <arg>-f <replaceable>file</replaceable></arg> </cmdsynopsis> </para> <para> Runs the parser with all default options, and try to analyze content of a single file identified by switch -f or --file </para> </listitem> </varlistentry> <varlistentry> <term> <parameter>-s</parameter> | <parameter>--string</parameter> </term> <listitem> <para> <cmdsynopsis> <command>pci</command> <arg>-s <replaceable>string</replaceable></arg> </cmdsynopsis> </para> <para> Runs the parser with all default options, and try to analyze content of a chunk of code (string) designed by switch -s or --string </para> </listitem> </varlistentry> <varlistentry> <term> <parameter>-v</parameter> | <parameter>--verbose</parameter> </term> <listitem> <para> <cmdsynopsis> <command>pci</command> <arg>-v <replaceable>number</replaceable></arg> <arg>-d <replaceable>directory</replaceable></arg> </cmdsynopsis> </para> <para> Runs the parser with all default options, and try to analyze content of files into directory identified by switch -d or --dir with the level of detail given by number and switch -v or --verbose </para> <para> Verbose level goes from 0 (no extra information) to 7 (full extra details). </para> <para> <itemizedlist> <listitem> <para> <emphasis role="bold">Level 0</emphasis> give only parsing results of data source (directory, file, string). </para> <para> For example: <command>pci -v 0 -d /tmp/Services_W3C_CSSValidator-0.1.0</command> give <screen> +-----------------------------+---------+---+------------+--------------------+ | Files | Version | C | Extensions | Constants/Tokens | +-----------------------------+---------+---+------------+--------------------+ | ...W3C_CSSValidator-0.1.0/* | 5.1.0 | 4 | pecl_http | ...CTORY_SEPARATOR | | | | | | __FILE__ | | | | | | instanceof | | | | | | protected | | | | | | public | +-----------------------------+---------+---+------------+--------------------+ | ...r-0.1.0/CSSValidator.php | 5.1.0 | 0 | pecl_http | protected | | | | | | public | +-----------------------------+---------+---+------------+--------------------+ | ...0.1.0/tests/AllTests.php | 5.0.0 | 4 | | __FILE__ | | | | | | public | +-----------------------------+---------+---+------------+--------------------+ | ...W3C_CSSValidatorTest.php | 5.0.0 | 4 | | ...CTORY_SEPARATOR | | | | | | __FILE__ | | | | | | protected | | | | | | public | +-----------------------------+---------+---+------------+--------------------+ | ...les/validate_atrules.php | 4.0.0 | 0 | | | +-----------------------------+---------+---+------------+--------------------+ | ...ples/validate_byfile.php | 4.0.0 | 0 | | | +-----------------------------+---------+---+------------+--------------------+ | ...mples/validate_byuri.php | 4.0.0 | 0 | | | +-----------------------------+---------+---+------------+--------------------+ | ...es/validate_fragment.php | 4.0.0 | 0 | | | +-----------------------------+---------+---+------------+--------------------+ | ...0/CSSValidator/Error.php | 5.0.0 | 0 | | public | +-----------------------------+---------+---+------------+--------------------+ | ...CSSValidator/Message.php | 5.0.0 | 0 | | public | +-----------------------------+---------+---+------------+--------------------+ | ...SSValidator/Response.php | 5.0.0 | 0 | | instanceof | | | | | | public | +-----------------------------+---------+---+------------+--------------------+ | ...CSSValidator/Warning.php | 4.0.0 | 0 | | | +-----------------------------+---------+---+------------+--------------------+ </screen> </para> </listitem> <listitem> <para> <emphasis role="bold">Level 1</emphasis> give same details as level 0, plus command line resume. </para> <para> For example: <command>pci -v 1 -d /tmp/Services_W3C_CSSValidator-0.1.0</command> give <screen> Command Line resume : +-------------------------+---------------------------------------------------+ | Option | Value | +-------------------------+---------------------------------------------------+ | summarize | FALSE | | output-level | 31 | | verbose | 1 | | dir | /tmp/Services_W3C_CSSValidator-0.1.0 | +-------------------------+---------------------------------------------------+ </screen> </para> </listitem> <listitem> <para> <emphasis role="bold">Level 2</emphasis> give same details as level 0, plus parser options used. </para> <para> For example: <command>pci -v 2 -d /tmp/Services_W3C_CSSValidator-0.1.0</command> give <screen> Parser options : +-------------------------+---------------------------------------------------+ | Option | Value | +-------------------------+---------------------------------------------------+ | file_ext | php | | | php4 | | | inc | | | phtml | | recurse_dir | TRUE | | debug | FALSE | | is_string | FALSE | | ignore_files | | | ignore_dirs | | +-------------------------+---------------------------------------------------+ </screen> </para> </listitem> <listitem> <para> <emphasis role="bold">Level 3</emphasis> is equivalent to level 2 + level 1 + level 0. </para> </listitem> <listitem> <para> <emphasis role="bold">Level 4</emphasis> give same details as level 0, plus list of php functions used with their version and source (extension PECL or standard). </para> <para> For example: <command>pci -v 4 -d /tmp/Services_W3C_CSSValidator-0.1.0</command> give <screen> Debug: +---------+-----------------+-----------+------+ | Version | Function | Extension | PECL | +---------+-----------------+-----------+------+ | 1.0.0 | http_request | pecl_http | yes | | 4.0.0 | in_array | | no | | 4.0.0 | file_exists | | no | | 4.0.0 | is_bool | | no | | 4.0.0 | intval | | no | | 4.0.0 | defined | | no | | 4.0.0 | define | | no | | 4.0.0 | chdir | | no | | 4.0.0 | dirname | | no | | 4.0.0 | realpath | | no | | 4.0.0 | error_reporting | | no | | 4.0.0 | ini_set | | no | | 4.0.0 | var_dump | | no | | 4.0.0 | get_object_vars | | no | | 5.1.0 | property_exists | | no | +---------+-----------------+-----------+------+ </screen> </para> </listitem> <listitem> <para> <emphasis role="bold">Level 5</emphasis> is equivalent to level 4 + level 1 + level 0. </para> </listitem> <listitem> <para> <emphasis role="bold">Level 6</emphasis> is equivalent to level 4 + level 2. </para> </listitem> <listitem> <para> <emphasis role="bold">Level 7</emphasis> is equivalent to level 4 + level 2 + level 1. </para> </listitem> </itemizedlist> </para> </listitem> </varlistentry> <varlistentry> <term> <parameter>-n</parameter> | <parameter>--no-recurse</parameter> </term> <listitem> <para> <cmdsynopsis> <command>pci</command> <arg>-n</arg> <arg>-d <replaceable>directory</replaceable></arg> </cmdsynopsis> </para> <para> Runs the parser and analyze only files in directory identified by -d or --dir. Default behavior will parse all directory childs recursively. </para> </listitem> </varlistentry> <varlistentry> <term> <parameter>-if</parameter> | <parameter>--ignore-files</parameter> </term> <listitem> <para> Identify the parameter text file that contains on each line the name of each file to ignore when parsing a directory/branch. </para> <para> Default value used <filename>files.txt</filename> file in the same directory as <command>pci</command> script. </para> </listitem> </varlistentry> <varlistentry> <term> <parameter>-id</parameter> | <parameter>--ignore-dirs</parameter> </term> <listitem> <para> Identify the parameter text file that contains on each line the name of each sub-directory to ignore when parsing a directory/branch. </para> <para> Default value used <filename>dirs.txt</filename> file in the same directory as <command>pci</command> script. </para> </listitem> </varlistentry> <varlistentry> <term> <parameter>-in</parameter> | <parameter>--ignore-functions</parameter> </term> <listitem> <para> Identify the parameter text file that contains on each line the name of each PHP function to ignore when parsing the data source. </para> <para> Default value used <filename>functions.txt</filename> file in the same directory as <command>pci</command> script. </para> </listitem> </varlistentry> <varlistentry> <term> <parameter>-ic</parameter> | <parameter>--ignore-constants</parameter> </term> <listitem> <para> Identify the parameter text file that contains on each line the name of each PHP constant to ignore when parsing the data source </para> <para> Default value used <filename>constants.txt</filename> file in the same directory as <command>pci</command> script. </para> </listitem> </varlistentry> <varlistentry> <term> <parameter>-ie</parameter> | <parameter>--ignore-extensions</parameter> </term> <listitem> <para> Identify the parameter text file that contains on each line the name of each PHP extension to ignore (all extension.functions) when parsing the data source </para> </listitem> </varlistentry> <varlistentry> <term> <parameter>-iv</parameter> | <parameter>--ignore-versions</parameter> </term> <listitem> <para> Expect one or two values that identify which PHP version (and all its related functions) to ignore. </para> <tip> <para> For example: ignore all PHP 5 functions (minor releases 0 thru 2), or only PHP 5.0.0 functions. <cmdsynopsis> <command>pci</command> <arg>-f <replaceable>file</replaceable></arg> <arg>-iv <replaceable>5.0.0</replaceable> <replaceable>5.2.0</replaceable></arg> </cmdsynopsis> <cmdsynopsis> <command>pci</command> <arg>-d <replaceable>directory</replaceable></arg> <arg>-iv <replaceable>5.0.0</replaceable></arg> </cmdsynopsis> </para> </tip> </listitem> </varlistentry> <varlistentry> <term> <parameter>-inm</parameter> | <parameter>--ignore-functions-match</parameter> </term> <listitem> <para> Identify the parameter text file that contains on each line a pattern (match a regular expression) of PHP function to ignore when parsing the data source. </para> <para> Default value used <filename>functions-match.txt</filename> file in the same directory as <command>pci</command> script. </para> <para> Comments start with &quot;;&quot;, as in php.ini, and blank lines are allowed. </para> <para> If you want to use the <emphasis role="bold">preg_match</emphasis> compare function, put a &quot;=&quot;, to start the line, follow by a regular expression. </para> </listitem> </varlistentry> <varlistentry> <term> <parameter>-iem</parameter> | <parameter>--ignore-extensions-match</parameter> </term> <listitem> <para> Identify the parameter text file that contains on each line a pattern (match a regular expression) of PHP extension to ignore when parsing the data source. </para> <para> Default value used <filename>extensions-match.txt</filename> file in the same directory as <command>pci</command> script. </para> <para> Comments start with &quot;;&quot;, as in php.ini, and blank lines are allowed. </para> <para> If you want to use the <emphasis role="bold">preg_match</emphasis> compare function, put a &quot;=&quot;, to start the line, follow by a regular expression. </para> </listitem> </varlistentry> <varlistentry> <term> <parameter>-icm</parameter> | <parameter>--ignore-constants-match</parameter> </term> <listitem> <para> Identify the parameter text file that contains on each line a pattern (match a regular expression) of PHP constant to ignore when parsing a directory, a single file, or a string. </para> <para> Default value used <filename>constants-match.txt</filename> file in the same directory as <command>pci</command> script. </para> <para> Comments start with &quot;;&quot;, as in php.ini, and blank lines are allowed. </para> <para> If you want to use the <emphasis role="bold">preg_match</emphasis> compare function, put a &quot;=&quot;, to start the line, follow by a regular expression. </para> </listitem> </varlistentry> <varlistentry> <term> <parameter>-fe</parameter> | <parameter>--file-ext</parameter> </term> <listitem> <para> Follow by a comma separated list of file extensions to parse (only valid if parsing a directory). Default is: php,php4,inc,phtml </para> </listitem> </varlistentry> <varlistentry> <term> <parameter>-r</parameter> | <parameter>--report</parameter> </term> <listitem> <para> Print either a text report (default), or any others render available (csv, xml, ...) </para> <para> For example: <cmdsynopsis> <command>pci</command> <arg>-r <replaceable>xml</replaceable></arg> <arg>-f <replaceable>/tmp/PHP_CodeSniffer-1.1.0/CodeSniffer.php</replaceable></arg> </cmdsynopsis> give these results (when package XML_Beautifier is available) <screen> <![CDATA[ <?xml version="1.0" encoding="UTF-8"?> <pci version="1.8.0"> <file name="/tmp/PHP_CodeSniffer-1.1.0/CodeSniffer.php"> <version>5.1.2</version> <conditions level="0" /> <extensions count="5"> <extension>date</extension> <extension>pcre</extension> <extension>spl</extension> <extension>tokenizer</extension> <extension>xml</extension> </extensions> <constants count="3"> <constant>DIRECTORY_SEPARATOR</constant> <constant>PHP_EOL</constant> <constant>__FILE__</constant> </constants> <tokens count="5"> <token>catch</token> <token>protected</token> <token>public</token> <token>throw</token> <token>try</token> </tokens> <ignored> <files count="0" /> <functions count="0" /> <extensions count="0" /> <constants count="0" /> </ignored> </pci> ]]> </screen> And with little debug option ( verbose level 4 ) <cmdsynopsis> <command>pci</command> <arg>-r <replaceable>xml</replaceable></arg> <arg>-v <replaceable>4</replaceable></arg> <arg>-f <replaceable>/tmp/PHP_CodeSniffer-1.1.0/CodeSniffer.php</replaceable></arg> </cmdsynopsis> results became <screen> <![CDATA[ <?xml version="1.0" encoding="UTF-8"?> <pci version="1.8.0"> <file>/tmp/PHP_CodeSniffer-1.1.0/CodeSniffer.php</file> <version>5.1.2</version> <conditions count="0" level="0" /> <extensions count="5"> <extension>date</extension> <extension>pcre</extension> <extension>spl</extension> <extension>tokenizer</extension> <extension>xml</extension> </extensions> <constants count="3"> <constant>DIRECTORY_SEPARATOR</constant> <constant>PHP_EOL</constant> <constant>__FILE__</constant> </constants> <tokens count="5"> <token>catch</token> <token>protected</token> <token>public</token> <token>throw</token> <token>try</token> </tokens> <ignored> <files count="0" /> <functions count="0" /> <extensions count="0" /> <constants count="0" /> </ignored> <functions count="41"> <function version="4.0.0">class_exists</function> <function version="4.0.0">define</function> <function version="4.0.0">chdir</function> <function version="4.0.0">dirname</function> <function version="4.0.0">substr</function> <function version="4.0.0">str_replace</function> <function version="4.0.0">is_file</function> <function version="4.0.0">is_array</function> <function version="4.0.0">is_string</function> <function version="4.0.0">count</function> <function version="4.0.0">is_dir</function> <function version="4.0.0">basename</function> <function version="4.0.0">realpath</function> <function version="4.0.0">strtolower</function> <function version="4.0.0">strrpos</function> <function version="4.0.0">in_array</function> <function version="4.0.0">explode</function> <function version="4.0.0">array_pop</function> <function version="4.0.0">array_merge</function> <function version="4.0.0">file_exists</function> <function version="4.0.0">strtr</function> <function extension="pcre" pecl="false" version="4.0.0">preg_match</function> <function extension="date" pecl="false" version="4.0.0">time</function> <function version="4.0.0">ksort</function> <function version="4.0.0">htmlspecialchars</function> <function extension="xml" pecl="false" version="4.0.0">utf8_encode</function> <function version="4.0.0">strlen</function> <function version="4.0.0">str_repeat</function> <function version="4.0.0">ord</function> <function version="4.0.0">strtoupper</function> <function version="4.0.0">strpos</function> <function version="4.0.0">rtrim</function> <function version="4.0.0">is_writable</function> <function version="4.0.2">wordwrap</function> <function version="4.0.4">is_null</function> <function version="4.0.4">constant</function> <function extension="tokenizer" pecl="false" version="4.2.0">token_name</function> <function version="4.2.0">var_export</function> <function version="5.0.0">file_put_contents</function> <function version="5.0.2">interface_exists</function> <function extension="spl" pecl="false" version="5.1.2">spl_autoload_register</function> </functions> </pci> ]]> </screen> </para> </listitem> </varlistentry> <varlistentry> <term> <parameter>-o</parameter> | <parameter>--output-level</parameter> </term> <listitem> <para> Allow to filter data type (column) you want on standard output (console). From all details (31=default) to only file name (=0) <itemizedlist> <listitem> <para> <emphasis role="bold">0:</emphasis> file name </para> </listitem> <listitem> <para> <emphasis role="bold">1:</emphasis> conditional code </para> </listitem> <listitem> <para> <emphasis role="bold">2:</emphasis> extensions </para> </listitem> <listitem> <para> <emphasis role="bold">4:</emphasis> constants </para> </listitem> <listitem> <para> <emphasis role="bold">8:</emphasis> tokens </para> </listitem> <listitem> <para> <emphasis role="bold">16:</emphasis> version </para> </listitem> </itemizedlist> <emphasis role="bold">output_level</emphasis> is binary value. So to have, for example, only file name (always mandatory) with version and extensions, you have to give value <emphasis role="bold">18</emphasis> (16 + 2). </para> </listitem> </varlistentry> <varlistentry> <term> <parameter>-t</parameter> | <parameter>--tab</parameter> </term> <listitem> <para> Sets the Files, Etensions and Constants/Tokens columns width. Default values are: 29 char. for Files colum, 12 char. for Extentions column, and 20 char. for Constants/Tokens column. </para> </listitem> </varlistentry> <varlistentry> <term> <parameter>-p</parameter> | <parameter>--progress</parameter> [ bar | text ] </term> <listitem> <para> Show a progress <literal>bar</literal> (if PEAR::Console_ProgressBar is installed) or a simple <literal>text</literal> wait message when parsing a directory. </para> <para> <note> <para> If you specify --progress bar and PEAR::Console_ProgressBar is not available, then default display will be text wait message (without giving an error), as if you have specified --progress text instead </para> </note> </para> </listitem> </varlistentry> <varlistentry> <term> <parameter>-S</parameter> | <parameter>--summarize</parameter> </term> <listitem> <para> Print only the summary of parsing result for a directory, rather than full details file by file (default). </para> </listitem> </varlistentry> <varlistentry> <term> <parameter>-V</parameter> | <parameter>--version</parameter> </term> <listitem> <para> Print only the current version information </para> </listitem> </varlistentry> <varlistentry> <term> <parameter>-h</parameter> | <parameter>--help</parameter> </term> <listitem> <para> Show help panel (as described in beginning of this section) </para> </listitem> </varlistentry> </variablelist> </para> <para> Let's take a look now at the result displayed : the main table </para> <para> <screen> +-----------------------------+---------+---+------------+--------------------+ | Files | Version | C | Extensions | Constants/Tokens | +-----------------------------+---------+---+------------+--------------------+ +-----------------------------+---------+---+------------+--------------------+ </screen> </para> <para> We have, by default (output-level = 31) 5 columns <note> <para> For Files, Extensions, Constants/Tokens columns, if content is larger than cell width, then the content if truncated by left, and replaced by <literal>...</literal> </para> </note> <itemizedlist> <listitem> <para> <emphasis role="bold">Files</emphasis> Identify each file of data source parsed. </para> </listitem> <listitem> <para> <emphasis role="bold">Version</emphasis> Give the minimum version to run the file. And if there is a second number, give the max version to run source file. </para> </listitem> <listitem> <para> <emphasis role="bold">C</emphasis> Show the level of conditional code found in your source file(s). From 0=none, 1=function_exists, 2=extension_loaded, 4=defined and more (its binary value). This C column is the same information given by <emphasis role="bold">cond_code</emphasis> in final hash result of Array Renderer. </para> </listitem> <listitem> <para> <emphasis role="bold">Extensions</emphasis> List the PHP standard or PECL extensions required to run the source file. </para> </listitem> <listitem> <para> <emphasis role="bold">Constants/Tokens</emphasis> List the PHP standard or user defined constants and PHP5+ tokens (such as: private, public, final, ...) </para> </listitem> </itemizedlist> </para> <para> When verbose mode is set to level 1, you have an additional table displayed, that resume the command line arguments </para> <para> <screen> Command Line resume : +-------------------------+---------------------------------------------------+ | Option | Value | +-------------------------+---------------------------------------------------+ +-------------------------+---------------------------------------------------+ </screen> </para> <para> When verbose mode is set to level 2, you have an additional table displayed, that resume the parser options used </para> <para> <screen> Parser options : +-------------------------+---------------------------------------------------+ | Option | Value | +-------------------------+---------------------------------------------------+ +-------------------------+---------------------------------------------------+ </screen> </para> <para> When verbose mode is set to level 4, you have an additional table displayed, that show each PHP standard or PECL functions with their version </para> <para> <screen> Debug: +---------+-----------------+-----------+------+ | Version | Function | Extension | PECL | +---------+-----------------+-----------+------+ +---------+-----------------+-----------+------+ </screen> </para> </refentry> <!-- 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 (#11014) next »