Re: New package `BoostlikeGetopt\'
| From: | Daniel O'Connor | Date: | Mon, 08 Mar 2010 05:53:59 +0000 |
| Subject: | Re: New package `BoostlikeGetopt\' | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-53300@lists.php.net to get a copy of this message | ||
Why not add a feature request + patch against the SVN version of
http://pear.php.net/package/console_getopt/
:)
On Mon, Mar 8, 2010 at 3:05 PM, Yokoyama, Shinobu <shinobu@yolcoyama.net>wrote:
> Although this is only a trivial Getopt package modification, I suppose the
> implementation helps quite a few of new Getopt users.
> Thanks to Andrei Zmievski (author of this package), here I want to request
> yet-another package named `BoostlikeGetopt\' ( or can be patch ? ).
>
> Additional methods:
> bool count(KEYNAME) : like boost `program_options\', only reports if
> option specified.
> mix operator [] : corresponding regular
get\' and
> set\' method.
>
> Additional members:
> $options : option values (former $getopt_args[0])
> $args : alias to non-option (former $getopt_args[1])
>
> Download source code:
> http://project.yolcoyama.net/open/php/BoostlikeGetopt.php
>
> Demo:
> To boost user, or even non-boost user who is new to Getopt, following
> code may illustrate how `boost-like\' superiors to array based access to
> options.
>
> -------- code[BEGIN] -----------
> require_once(\"Console/BoostlikeGetopt.php\");
> $opt = new Console_Getopt;
> $opt->getopt($opt->readPHPArgv(), \"hm:\", array(\"help\"));
> if(@PEAR::isError($opt)){
> fprintf(STDERR, $opt->getMessage());
> exit(1);
> }
> echo \"`h\' option:\\n\"; var_dump($opt->count(\"h\"),
> $opt[\"h\"]);
> echo \"\\n`m\' option:\\n\"; var_dump($opt->count(\"m\"),
> $opt[\"m\"]);
>
> $opt[\"m\"] = 64;
>
> echo \"\\nmodified `m\' option:\\n\"; var_dump($opt->count(\"m\"),
> $opt[\"m\"]);
>
> /* output: */
> /* $ ./demo.php -m 32 -h */
> /* `h\' option: */
> /* bool(true) */
> /* NULL */
>
> /* `m\' option: */
> /* bool(true) */
> /* string(2) \"32\" */
>
> /* modified `m\' option: */
> /* bool(true) */
> /* int(64) */
> -------- code[END] -----------
>
> Thank you.
>
>
> --
> PEAR Development Mailing List (http://pear.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>