Re: [Console_CommandLine] subcommand in xml file
| From: | Reuben Cummings | Date: | Sun, 30 Nov 2008 18:37:47 +0000 |
| Subject: | Re: [Console_CommandLine] subcommand in xml file | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-29469@lists.php.net to get a copy of this message | ||
Thanks, this program is awesome!! I'll add the following which I just
figured out...
print_r($result->options); // options passed to main command
print_r($result->args); // arguments passed to main command
print_r("$result->command_name\n"); // name of subcommand
print_r($result->command->options); // options passed to subcommand
print_r($result->command->args); // arguments passed to subcommand
also, your example in the pear manual has a typo. It should read
'print_r($result);' instead of 'print_r($results);'
Reuben
On Wed, Nov 26, 2008 at 4:17 PM, David Jean Louis <izimobil@gmail.com> wrote:
> 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 Cummings
>>
>
> Hi 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>
>