Re: [Console_CommandLine] read '-' as an argument
| From: | David Jean Louis | Date: | Thu, 03 Nov 2011 07:59:05 +0000 |
| Subject: | Re: [Console_CommandLine] read '-' as an argument | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-31295@lists.php.net to get a copy of this message | ||
Hi,
How do I set up the parser to read '-' as an argument? I want an option to read from standard input and most other cli programs use '-'. I want to be able to type the following: echo argument | myprogram - When I try this with Console_CommandLine, it just hangs so I have to use another character instead (I use '$').Well, it works for me: test.php:| <?php|| require_once 'Console/CommandLine.php'; $parser = new Console_CommandLine(); $parser->addArgument('data'); try {
$result = $parser->parse();
print_r($result->args);
} catch (Exception $exc) {
$parser->displayError($exc->getMessage());} ?>| |$ echo foo |php test.php - Array (
[data] => foo)| -- David