You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by bu...@apache.org on 2004/05/04 21:31:26 UTC

DO NOT REPLY [Bug 28774] New: - [PATCH] Use of Jakarta Commons CLI library for command line processing

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=28774>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=28774

[PATCH] Use of Jakarta Commons CLI library for command line processing

           Summary: [PATCH] Use of Jakarta Commons CLI library for command
                    line processing
           Product: Fop
           Version: 1.0dev
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: general
        AssignedTo: fop-dev@xml.apache.org
        ReportedBy: spepping@leverkruid.nl


This patch introduces the Jakarta Commons CLI library for command line
processing, in apps/CommandLineOptions.java. It is meant to raise the
question whether this library is useful enough for FOP to use it and
thereby introduce a dependency on another library.

Features: Short and long forms for all options. Any order of the
options is allowed and options and arguments may be mixed freely. The
application may process the options in any order, independently of the
order in which they were specified; the order of multiple
specifications of the same option is retained.

The library does not guard against multiple specifications of the same
option, and the application cannot specify whether that is allowed or
not. Normal option value retrieval retrieves the first specified
value. To obtain all values a different call should be made, see
option 'param'.

In this patch I implemented the same command line conventions as the
current code. There is one exception; I changed '-print help' to '-h
print', because it is more difficult to return an option value to the
command line if it is not a specific value, and for '-h' it seems more
logical to assume always that the following non-option is an option
value and not an argument. Usage of the library would make it easy to
implement a different convention, e.g. Posix (one-letter short
options). The current convention is called GNU by the library,
although GNU applications usually use the GNU getops CLI library,
which implements Posix.

Elsewhere in the code I replaced a few Booleans with calls to the
parsed command line, e.g. "if (cl.hasOption('x'))" instead of 'if
(showConfiguration == Boolean.TRUE)'. Otherwise the code has remained
rather similar, except for options specification and parsing.

The current release of commons-cli is labeled 1.0-beta-2-dev. Peter
West uses commons-cli in his code. There was a discussion about
commons-cli on this list just over a year ago:
http://marc.theaimsgroup.com/?t=105105418200006&r=1&w=2