Comments for "Console_GetoptPlus"

» Submit Your Comment
Comments are only accepted during the "Proposal" phase. This proposal is currently in the "Finished" phase.
» Comments
  • Travis Swicegood  [2008-01-10 20:15 UTC]

    What are the differences, short of API, between this and the recent Console_CommandLine proposal that was accepted?
  • Michel Corne  [2008-01-11 08:52 UTC]

    In reply to Travis' comment, the main differences between GetoptPlus and Console_CommandLine are the following:

    + GetoptPlus implements getopt(), getopt2(), doGetopt(), readPHPArgv() as in Console_getopt. It is PHP5 code and it throws Exception instead of using PEAR_ERROR. This was the main driver for writing this package, in line with PEAR's guidance to port packages from PHP4 to PHP5.

    + Other packages use Console_getopt or implement very similar built-in command line parsing mechanisms, they could easily benefit from GetoptPlus.

    + The getoptplus() enhanced method uses a simple array-based description of the command to specify option short names, long names, their types and
    usage. There is no need to call additional methods.

    + getoptplus() accepts option name shortcuts such as "--f" or "--for" for "--format". This is similar to other command line parsers and it is nice to have.

    + GetoptPlus will soon implement a Web interface to run command line through a browser.

    = GetoptPlus and Console_CommandLine can both generate the command usage automatically.

    - GetoptPlus does not handle sub commands nor option value types (or actions).

    As a side note, the package has been on sourceforge for 7 months or so. It took me that long to propose it to the Pear community: my bad... GetoptPlus is fully tested and production ready. I am already using it as a built-in class in other packages. I really would like to use it as a separate package, hoping it will be accepted. I believe there is room for both packages as they meet different needs.
  • Michel Corne  [2008-01-11 17:19 UTC]

    In reply Jean Louis' questions on some functionalities:

    + Yes, GetoptPlus handles the '--' special option that stops options parsing and consider further tokens as parameters

    + Yes, long options can be separated from the argument with '=' or by a space

    + Yes, '-' alone is handled as the standard input (stdin) flag and remaining tokens are considered as parameters, as per Console_getopt

    + Yes, it is POSIX compliant (first non-option stops option processing) BUT there is no other mode; this could be added as an enhancement as you are suggesting.