Re: [te-code-users] [ te-code-Feature Requests-1513562 ] Modify usage according to contraints
Brought to you by:
atownley
|
From: Andrew S. T. <ato...@ei...> - 2006-06-30 14:18:27
|
Hi JP, I agree that this type of thing would be a good addition, but it would certainly add a lot of complexity to the help output generators. I know I put the RequiredOptionConstraint in the package, but I'm still sorta arguing with myself about the oxymoron of having something 'optional' be 'required' for correctness. :) What I have often done in this case in later tools I've written is simply added the required parameters to the description given to the constructor of the CommandParser (see the current examples/feather.java, line 59). If the required arguments aren't terribly obvious, you can then include the information in the preamble with either the AutoHelpListener.setHeader() or the CommandParser.setExtraHelpText() method, depending on your preference (based on the current source in CVS). While you lose the benefits of being able to handle the action in the execute method of your CommandOption class, it is, as I said, arguably more correct. Of course, if you need/want to do it this way for some other reasons, then that's different. :) Of the things I still want to do with the library (when I can get some time away from the "real job"), this is pretty low on my priority list. I do agree it would be useful, however, so feel free to contribute a patch against the current CVS if you would like. If it looks good and has unit tests, I'll accept it into the codestream. Thanks very much for the feedback, ast On Tue, 2006-06-27 at 22:32, SourceForge.net wrote: > Feature Requests item #1513562, was opened at 2006-06-27 15:06 > Message generated for change (Comment added) made by jbeaudry > You can respond by visiting: > https://sourceforge.net/tracker/?func=detail&atid=567061&aid=1513562&group_id=82738 > > Please note that this message will contain a full copy of the comment thread, > including the initial issue submission, for this request, > not just the latest update. > Category: Interface Improvements (example) > Group: None > Status: Open > Priority: 5 > Submitted By: Nobody/Anonymous (nobody) > Assigned to: Nobody/Anonymous (nobody) > Summary: Modify usage according to contraints > > Initial Comment: > Hi, > > I was wondering if it would be possible to have the > displayed usage tailored according to the contraints added? > > For example, if I have my 'program', with a mandatory > option called 'name' and execute it like this: > > bash#program > > I get the message: > > error: option 'name' is required. Exiting. > Usage: program [-n|--name <arg>] > > Since 'name' is not optional, ideally the usage would show: > > error: option 'name' is required. Exiting. > Usage: program -n|--name <arg> > > You could imagine more complicated scenarios when at > last one option of a group is mandatory. > > Thanks, > JP > > > ---------------------------------------------------------------------- > > Comment By: JP Beaudry (jbeaudry) > Date: 2006-06-27 16:32 > > Message: > Logged In: YES > user_id=829770 > > Doh, didn't mean to put in an anonymous request. > > Feel free to contact me if I can clarify the above. > > Thanks > > ---------------------------------------------------------------------- > > You can respond by visiting: > https://sourceforge.net/tracker/?func=detail&atid=567061&aid=1513562&group_id=82738 -- Andrew S. Townley <ato...@ei...> http://atownley.org |