Created
January 18, 2013 23:11
-
-
Save wspeirs/4569478 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// check to see if they need help | |
// notice we only use the short-version, but it checks both! | |
if(cmdLine.hasOption("h")) { | |
new HelpFormatter().printHelp("sop4j-cli", options); | |
return; | |
} | |
// check to see if they passed in an opt | |
// recommended to use the long version as it's more readable | |
if(cmdLine.hasOption("opt")) { | |
System.out.println("Found opt!"); | |
} | |
// get -D options and their values | |
if(cmdLine.hasOption("D")) { | |
Properties props = cmdLine.getOptionProperties("D"); | |
for(Entry<Object, Object> entry:props.entrySet()) { | |
System.out.println("Property: " + entry.getKey() + " " + entry.getValue()); | |
} | |
} | |
// see if we have a file option by checking it's value | |
String file = null; | |
if(null != (file = cmdLine.getOptionValue("file")) ) { | |
System.out.println("File option: " + file); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment