commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 33340] New: - HelpFormatter doesn't function correctly for options with only LongOpt
Date Tue, 01 Feb 2005 22:45:03 GMT
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=33340>.
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=33340

           Summary: HelpFormatter doesn't function correctly for options
                    with only LongOpt
           Product: Commons
           Version: 1.0 Final
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P3
         Component: CLI
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: scruffy323@aol.com


The following doesn't work (org.apache.commons.cli.HelpFormatter
)correctly and doesn't print out the help menu of options
that only specify LongOpt.


The output is:
 [java] usage: -a | -d | --shutdown  |  -s | -h [-r <email>] [-f <flight>] [-t]
     [java] VendMore - Email Management System
     [java]  -t,--test       test mode - makes no permanent changes.
     [java]     --shutdown   shutdown rpc server.
     [java]  -a,--add        add user to email queue.
     [java]  -d,--delete     delete user from email queue.
     [java]  -f,--flight     flight which is the index into the email being sent
     [java]  -h,--help       Print this usage information.
     [java]  -r              recipient's email
     [java]  -s,--send       send email command
     [java]  For more information, see Steve Morin
     [java] Java Result: 1




it is missing the following options when printing the help display.




   options.addOption(OptionBuilder.withDescription("hostname for the XmlRpc
client to connect to.").withLongOpt("hostname").create());
        options.addOption(OptionBuilder.withDescription("port for the xmlrpc
client to use.").withLongOpt("port").create());
        options.addOption(OptionBuilder.withDescription("additional xmlrpc
connection").withLongOpt("urlpath").create());
             options.addOption(OptionBuilder.withDescription("add a parameter
form name=value.").hasArg().withLongOpt("params").create());




example of the offending code

    private CommandLineParser cmd;
    private Options options;
    private OptionGroup ogmain;
    
    public CmdLineArg() {
        super();
        cmd = new BasicParser();
        options = new Options();
        ogmain = new OptionGroup();
        ogmain.setRequired(true);
        localinit();
        init();
    }


 public CommandLine run(String[] args) {
        
        try {
             options.addOption(OptionBuilder.withDescription("add a parameter
form name=value.").hasArg().withLongOpt("params").create());
             options.addOption(OptionBuilder.withDescription("recipient's
email").hasArg().create('r'));
             options.addOption(OptionBuilder.withDescription("flight which is
the index into the email being sent").withLongOpt("flight").hasArg().create('f'));
             options.addOption(OptionBuilder.withDescription("test mode - makes
no permanent changes.").withLongOpt("test").create('t'));

        
        
             ogmain.addOption(OptionBuilder.withDescription("Print this usage
information.").withLongOpt("help").create('h'));
             ogmain.addOption(OptionBuilder.withDescription("send email
command").withLongOpt("send").hasArg().create('s'));

        ogmain.addOption(OptionBuilder.withDescription("add user to email
queue.").withLongOpt("add").create('a'));
        ogmain.addOption(OptionBuilder.withDescription("delete user from email
queue.").withLongOpt("delete").create('d'));
        ogmain.addOption(OptionBuilder.withDescription("shutdown rpc
server.").withLongOpt("shutdown").create());
        
        options.addOption(OptionBuilder.withDescription("hostname for the XmlRpc
client to connect to.").withLongOpt("hostname").create());
        options.addOption(OptionBuilder.withDescription("port for the xmlrpc
client to use.").withLongOpt("port").create());
        options.addOption(OptionBuilder.withDescription("additional xmlrpc
connection").withLongOpt("urlpath").create());


            options.addOptionGroup(this.ogmain);
            return cmd.parse(options,args);
        } catch (ParseException e) {
            printUsage();
            System.exit(1);
            return null;
        }
    }
    
    protected void printUsage(){
        HelpFormatter helpFormatter = new HelpFormatter();
        helpFormatter.printHelp(getUSAGE(),getHEADER(),options,getFOOTER());
    }

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message