Skip to content

Instantly share code, notes, and snippets.

@andrewm4894
Created May 1, 2019 15:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewm4894/0e9d741126d7c8add261724868d4a844 to your computer and use it in GitHub Desktop.
Save andrewm4894/0e9d741126d7c8add261724868d4a844 to your computer and use it in GitHub Desktop.
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