Skip to content

Instantly share code, notes, and snippets.

@Kanasansoft
Created June 8, 2011 14:24
Show Gist options
  • Save Kanasansoft/1014512 to your computer and use it in GitHub Desktop.
Save Kanasansoft/1014512 to your computer and use it in GitHub Desktop.
[don't use it] wrapper => command line arguments parser library
import java.util.List;
import com.sampullara.cli.Args;
import com.sampullara.cli.Argument;
class CommandLineOption {
@Argument(value = "help", alias = "h")
private Boolean helpFlag = false;
List<String> extra = null;
@Argument(value = "port", alias = "p", description = "This is the port number")
Integer portNo;
CommandLineOption(String[] args) {
if (args == null) {
args = new String[] {};
}
try {
extra = Args.parse(this, args);
} catch (IllegalArgumentException e) {
System.err.println(e.getLocalizedMessage());
System.exit(1);
}
if (helpFlag) {
Args.usage(this);
System.exit(0);
}
}
}
<dependency>
<groupId>com.google.code.cli-parser</groupId>
<artifactId>cli</artifactId>
<version>7</version>
</dependency>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment