0
|
1 <?php
|
|
2
|
|
3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
|
4
|
|
5 /**
|
|
6 * This file is part of the PEAR Console_CommandLine package.
|
|
7 *
|
|
8 * A simple example demonstrating the use of choices argument validation.
|
|
9 *
|
|
10 * PHP version 5
|
|
11 *
|
|
12 * @category Console
|
|
13 * @package Console_CommandLine
|
|
14 * @author Laurent Laville <pear@laurent-laville.org>
|
|
15 * @link http://pear.php.net/package/Console_CommandLine
|
|
16 */
|
|
17
|
|
18 // Include the Console_CommandLine package.
|
|
19 require_once 'Console/CommandLine.php';
|
|
20
|
|
21 // create the parser
|
|
22 $xmlfile = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'ex5.xml';
|
|
23 $parser = Console_CommandLine::fromXmlFile($xmlfile);
|
|
24
|
|
25 // run the parser
|
|
26 try {
|
|
27 $result = $parser->parse();
|
|
28 if ($result->command_name) {
|
|
29 $st = implode(', ', $result->command->args['item']);
|
|
30 echo "List says: $st\n";
|
|
31 }
|
|
32 } catch (Exception $exc) {
|
|
33 $parser->displayError($exc->getMessage());
|
|
34 }
|
|
35
|
|
36 ?>
|