- Project tools
-
-
-
- How do I...
-
| Category |
Featured projects |
| scm |
Subversion,
Subclipse,
TortoiseSVN,
RapidSVN
|
| issuetrack |
Scarab |
| requirements |
xmlbasedsrs |
| design |
ArgoUML |
| techcomm |
SubEtha,
eyebrowse,
midgard,
cowiki |
| construction |
antelope,
scons,
frameworx,
build-interceptor,
propel,
phing
|
| testing |
maxq,
aut
|
| deployment |
current |
| process |
ReadySET |
| libraries |
GEF,
Axion,
Style,
SSTree
|
| Over 500 more tools... |
|
optparse
Project home
If you were registered and logged in, you could join this project.
Abstract The optparse liibrary provides a very simple and straightforward API for basic command line option parsing. It is kept as simple as possible to ensure instant usage without bothering the API user with unnecessary (because rather standard) configuration stuff. Therefore some assumptions are made which should fit almost all usage scenarios but might not fit your special one.
Well, why use this? Yes, we all know -- there are already more than enough option parsing solutions around. But none of these kept it as simple as this one. Example Just a silly example to sketch what this is all about. This example parses all kinds of supported option styles. Apart from that it features my personally preferred configuration style (a fluent interface). public static void main ( String[] args ) { OptionParser optionParser = new OptionParser() .register( new OptionalFlag( "flag", 'f' ) ) .register( new MandatoryParameter( "type", 't' ) ) .register( new OptionalParameter( "values" ) ); optionParser.parse( args ); // optional: throw Exception if mandatory options are not defined optionParser.assertMandatoryOptions(); // optional: throw Exception if parameters have no value optionParser.assertMandatoryOptionValues(); // optional: throw Exception if unknown options ocurred optionParser.assertUnregisteredOptions(); // getOption will only return null if the option was not registered System.out.println( "Flag: " + optionParser.getOption( "flag" ).isAvailable() ? "true" : "false"; System.out.println( "Type: " + optionParser.getOption( "type" ).getValue() ); Option valuesOption = optionParser.getOption( "values" ); System.out.println( "Input: " + valuesOption.isAvailable() ? valuesOption.getValues().toString : "not provided"; } Please do not bother me because of the missing exception handling or any other totally great code tweaks. This is just an example. News - 2009-10-19
- Released version 0.2. I've rewritten the API to allow multiple different configuration styles including a fluent API.
- 2005-05-12
- Switched to SVN repository.
Development The optparse library is currently developed for Java 5 due to the use of Java Generics. Annotations are not part of the implementation and probably never will be. Currently no additional third party libraries are needed and a main goal is to keep it that way. After all it's just option parsing. The optparse library is released and distributed via Maven2. All tests are implemented using the TestNG and jMock testing frameworks. Project History - 0.1 - Basic Release
- First public version doing just what anyone would expect it to do. Documentation and tests are complete though.
Project Roadmap Nothing planned at the moment.
|