comparison vendor/pear/console_commandline/docs/examples/ex2.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 * This example demonstrate the use of xml definitions files with
9 * Console_CommandLine, the result is the same as for the ex1.php file.
10 *
11 * PHP version 5
12 *
13 * LICENSE: This source file is subject to the MIT license that is available
14 * through the world-wide-web at the following URI:
15 * http://opensource.org/licenses/mit-license.php
16 *
17 * @category Console
18 * @package Console_CommandLine
19 * @author David JEAN LOUIS <izimobil@gmail.com>
20 * @copyright 2007 David JEAN LOUIS
21 * @license http://opensource.org/licenses/mit-license.php MIT License
22 * @version CVS: $Id$
23 * @link http://pear.php.net/package/Console_CommandLine
24 * @since File available since release 0.1.0
25 */
26
27 // Include the Console_CommandLine package.
28 require_once 'Console/CommandLine.php';
29
30 // create the parser from xml file
31 $xmlfile = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'ex2.xml';
32 $parser = Console_CommandLine::fromXmlFile($xmlfile);
33
34
35 // run the parser
36 try {
37 $result = $parser->parse();
38 // write your program here...
39 print_r($result->options);
40 print_r($result->args);
41 } catch (Exception $exc) {
42 $parser->displayError($exc->getMessage());
43 }
44
45 ?>