Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
#!/usr/bin/php
2
<?php
3
/**
4
 * This is an example with Console_Getoptplus::getoptplus() including a header,
5
 * the usage, and a footer.
6
 *
7
 * Examples to run on the command line:
8
 * #full --help
9
 * #full -h
10
 */
11
 
12
require_once 'Console/GetoptPlus.php';
13
 
14
try {
15
    $config = array(// /
16
        'header' => array('The getoptplus command with default settings behaves like getopt.',
17
            'Note that the header is optional.'),
18
        'usage' => array('--foo', '--bar <arg> -c [arg]'),
19
        'options' => array(// /
20
            array('long' => 'foo', 'type' => 'noarg',
21
                'desc' => array('An option without argument with only the long', 'name defined.')),
22
            array('long' => 'bar', 'type' => 'mandatory', 'short' => 'b',
23
                'desc' => array('arg', 'A mandatory option with both the long and', 'the short names defined.')),
24
            array('short' => 'c', 'type' => 'optional',
25
                'desc' => array('arg', 'An option with an optional argument with only', 'the short name defined.'))),
26
        'parameters' => array('[param1] [param2]', 'Some additional parameters.'),
27
        'footer' => array('Some additional information. Note that the footer is optional.',
28
            'Also, the usage has a default if it is absent from the configuration.'),
29
        );
30
 
31
    $options = Console_Getoptplus::getoptplus($config);
32
    print_r($options);
33
}
34
catch(Console_GetoptPlus_Exception $e) {
35
    $error = array($e->getCode(), $e->getMessage());
36
    print_r($error);
37
}
38
 
39
?>