Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
// 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);
// 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
You can’t perform that action at this time.