comparison vendor/pear/console_commandline/docs/examples/ex5.php @ 0:1e000243b222

vanilla 1.3.3 distro, I hope
author Charlie Root
date Thu, 04 Jan 2018 15:50:29 -0500
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:1e000243b222
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 ?>