| 1 |
lars |
1 |
#!/usr/bin/php
|
|
|
2 |
<?php
|
|
|
3 |
|
|
|
4 |
// php2 --help
|
|
|
5 |
// php2 -h
|
|
|
6 |
// php2 -a -c /tmp -d foo=bar -H -s --rf test arg1 arg2
|
|
|
7 |
|
|
|
8 |
require_once 'Console/GetoptPlus.php';
|
|
|
9 |
|
|
|
10 |
$config = array(// /
|
|
|
11 |
'usage' => array(// /
|
|
|
12 |
'[options] [-f] <file> [--] [args...]',
|
|
|
13 |
'[options] -r <code> [--] [args...]',
|
|
|
14 |
'[options] [-B <begin_code>] -R <code> [-E <end_code>] [--] [args..]',
|
|
|
15 |
'[options] [-B <begin_code>] -F <file> [-E <end_code>] [--] [args..]',
|
|
|
16 |
'[options] -- [args...]',
|
|
|
17 |
'[options] -a',
|
|
|
18 |
),
|
|
|
19 |
'options' => array(// /
|
|
|
20 |
array('short' => 'a', 'type' => 'noarg',
|
|
|
21 |
'desc' => array('Run interactively')),
|
|
|
22 |
array('short' => 'c', 'type' => 'mandatory',
|
|
|
23 |
'desc' => array('path>|file', 'Look for php.ini file in this directory')),
|
|
|
24 |
array('short' => 'n', 'type' => 'noarg',
|
|
|
25 |
'desc' => array('No php.ini file will be used')),
|
|
|
26 |
array('short' => 'd', 'type' => 'mandatory',
|
|
|
27 |
'desc' => array('foo[=bar]', "Define INI entry foo with value 'bar'")),
|
|
|
28 |
array('short' => 'e', 'type' => 'noarg',
|
|
|
29 |
'desc' => array('Generate extended information for', 'debugger/profiler')),
|
|
|
30 |
array('short' => 'f', 'type' => 'mandatory',
|
|
|
31 |
'desc' => array('file', 'Parse and execute <file>.')),
|
|
|
32 |
array('short' => 'i', 'type' => 'noarg',
|
|
|
33 |
'desc' => array('PHP information')),
|
|
|
34 |
array('short' => 'l', 'type' => 'noarg',
|
|
|
35 |
'desc' => array('Syntax check only (lint)')),
|
|
|
36 |
array('short' => 'm', 'type' => 'noarg',
|
|
|
37 |
'desc' => array('Show compiled in modules')),
|
|
|
38 |
array('short' => 'r', 'type' => 'mandatory',
|
|
|
39 |
'desc' => array('code', 'Run PHP <code> without using script tags <?..?>')),
|
|
|
40 |
array('short' => 'B', 'type' => 'mandatory',
|
|
|
41 |
'desc' => array('begin_code', 'Run PHP <begin_code> before processing', 'input lines')),
|
|
|
42 |
array('short' => 'R', 'type' => 'mandatory',
|
|
|
43 |
'desc' => array('code', 'Run PHP <code> for every input line')),
|
|
|
44 |
array('short' => 'F', 'type' => 'mandatory',
|
|
|
45 |
'desc' => array('file', 'Parse and execute <file> for every input line')),
|
|
|
46 |
array('short' => 'E', 'type' => 'mandatory',
|
|
|
47 |
'desc' => array('end_code', 'Run PHP <end_code> after processing', 'all input lines')),
|
|
|
48 |
array('short' => 'H', 'type' => 'noarg',
|
|
|
49 |
'desc' => array('Hide any passed arguments from external tools.')),
|
|
|
50 |
array('short' => 's', 'type' => 'noarg',
|
|
|
51 |
'desc' => array('Display colour syntax highlighted source.')),
|
|
|
52 |
array('short' => 'v', 'type' => 'noarg',
|
|
|
53 |
'desc' => array('Version number')),
|
|
|
54 |
array('short' => 'w', 'type' => 'noarg',
|
|
|
55 |
'desc' => array('Display source with stripped comments and', 'whitespace.')),
|
|
|
56 |
array('short' => 'z', 'type' => 'mandatory',
|
|
|
57 |
'desc' => array('file', 'Load Zend extension <file>.')),
|
|
|
58 |
array('long' => 'rf', 'type' => 'mandatory',
|
|
|
59 |
'desc' => array('name', 'Show information about function <name>.')),
|
|
|
60 |
array('long' => 'rc', 'type' => 'mandatory',
|
|
|
61 |
'desc' => array('name', 'Show information about class <name>.')),
|
|
|
62 |
array('long' => 're', 'type' => 'mandatory',
|
|
|
63 |
'desc' => array('name', 'Show information about extension <name>.')),
|
|
|
64 |
),
|
|
|
65 |
|
|
|
66 |
'parameters' => array('args...',
|
|
|
67 |
'Arguments passed to script. Use -- args when first argument',
|
|
|
68 |
'starts with - or script is read from stdin'),
|
|
|
69 |
);
|
|
|
70 |
|
|
|
71 |
try {
|
|
|
72 |
$options = Console_GetoptPlus::getoptplus($config, null, true);
|
|
|
73 |
print_r($options);
|
|
|
74 |
}
|
|
|
75 |
catch(Console_GetoptPlus_Exception $e) {
|
|
|
76 |
$error = array($e->getCode(), $e->getMessage());
|
|
|
77 |
print_r($error);
|
|
|
78 |
}
|
|
|
79 |
|
|
|
80 |
?>
|