Command-line class generation tool
Example from previous section looks pretty simple, but it does not
handle any errors which may occur during parsing of XML source. The
package provides a command-line script to make generation of classes
even more simple, and takes care of possible errors. It installs in
scripts/Text/Highlighter
directory and is called generate (on Unix/Linux)
or generate.bat (on Windows).
This script is able to process multiple files in one run, and also to
process XML from standard input and write generated code to standard
output.
Usage:
generate options
Options:
-x filename, --xml=filename
source XML file. Multiple input files can be specified, in which
case each -x option must be followed by -p unless -d is specified
Defaults to stdin
-p filename, --php=filename
destination PHP file. Defaults to stdout. If specied multiple times,
each -p must follow -x
-d dirname, --dir=dirname
Default destination directory. File names will be taken from XML input
("lang" attribute of <highlight> tag)
-h, --help
This help
Examples
Read from php.xml, write to PHP.php
generate -x php.xml -p PHP.php
|
Read from php.xml, write to standard output
Read from php.xml, write to PHP.php, read from xml.xml, write to
XML.php
generate -x php.xml -p PHP.php -x xml.xml -p XML.php
|
Read from php.xml, write to /some/dir/PHP.php, read from xml.xml, write to
/some/dir/XML.php (assuming that xml.xml contains <highlight
lang="xml">
, and php.xml contains <highlight
lang="php">
)
generate -x php.xml -x xml.xml -d /some/dir/
|