Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.Option;
/**
* Hello world! class that is paramaterized (with defaults) using arg4j.
* Example cli usage: java -jar helloWorldParamaterized --msg='Hello arg4j!'
*/
public class helloWorldParamaterized
{
@Option(name="--msg")
private String msg = "Hello World!";
public static void main(String[] args) throws Exception {
new helloWorldParamaterized().doMain(args);
}
public void doMain(String[] args) throws Exception {
// make a parser
CmdLineParser parser = new CmdLineParser(this);
// parse args
parser.parseArgument(args);
// print message passed in from args
System.out.println(msg);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment