|
f=Example demonstrating the use of xml definitions= Example 2 php file<?php
// Include the Console_CommandLine package.
require_once 'Console/CommandLine.php';
// create the parser from xml file
$xmlfile = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'ex2.xml';
$parser = Console_CommandLine::fromXmlFile($xmlfile);
// run the parser
try {
$result = $parser->parse();
// todo: your program here ;)
print_r($result->options);
print_r($result->args);
} catch (Exception $exc) {
$parser->displayError($exc->getMessage());
}
?>Example 2 xml file<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<command>
<description>zip given files using the php zip module.</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>
<option name="delete">
<short_name>-d</short_name>
<long_name>--delete</long_name>
<description>delete original files after zip operation</description>
<action>StoreTrue</action>
</option>
<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>
|