Re: [Console_CommandLine] subcommand in xml file
| From: | David Jean Louis | Date: | Wed, 26 Nov 2008 21:17:51 +0000 |
| Subject: | Re: [Console_CommandLine] subcommand in xml file | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-29451@lists.php.net to get a copy of this message | ||
Reuben Cummings a écrit :
Hi again. This one should be pretty easy. How do I add subcommands in the xml file? If this isn't possible, what is the least amount of code that needs to be in the commandline handling code and how do I integrate it with the rest of the xml file? Thanks. Reuben CummingsHi again Reuben, Sure, this is possible, just do something like: (example taken from Console_CommandLine tests) <?php $xml = '<?xml version="1.0" encoding="utf-8" standalone="yes"?> <command>
<name>test</name>
<description>zip/unzip files</description>
<version>1.0.0</version>
<option name="verbose">
<short_name>-v</short_name>
<long_name>--verbose</long_name>
<description>turn on verbose output</description>
<action>StoreTrue</action>
</option>
<command>
<name>zip</name>
<description>zip given files in the destination file</description>
<argument name="files">
<description>a list of files to zip together</description>
<multiple>true</multiple>
</argument>
<argument name="zipfile">
<description>path to the zip file to generate</description>
</argument>
</command>
<command>
<name>unzip</name>
<description>unzip given file in the destination dir</description>
<argument name="zipfile">
<description>path to the zip file to unzip</description>
</argument>
<argument name="outputdir">
<description>destination directory</description>
</argument>
</command>
</command>';
$parser = Console_CommandLine::fromXmlString($xml);
$parser->parse();
?>
Sub-commands will be documented as soon as possible, I just don't have the time right now.
--
David JEAN LOUIS <izimobil@gmail.com>