These command line parameters are part of the Configuration system... you can set it using "-Ddw.foo=value",
For those (like me) reading this thread much later, you don't need to use the -Ddw.foo=bar format if you don't want to. You can just grab strings off the command line like a regular java app, but your command class has to override the configure() method. So let's say you want to be able to pass in "bar" as a command line argument.
e.g. java -jar myDropWizardApp.jar mycommand bar
Your command class would need to look like this:
public class MyCommand extends Command<MyConfiguration> {
public MyCommand() {
super("mycommand", "Read a string off the command line");
}
public void configure(Subparser argParser) {
argParser.addArgument("foo").nargs("?").help("Optional command line string.");
}
@Override
protected void run(Bootstrap<ViolationsConfiguration> bootstrap,
Namespace namespace, ViolationsConfiguration configuration)
throws Exception {
String fooValue= namespace.getString("foo");
...
}
}
Variations:
If your command is a ConfiguredCommand you need to add
super.configure(argParser);
as the first line of your configure() method or the YML file won't be read.
If you want a non-optional string try
argParser.addArgument("foo").nargs(1).help("Required command line string.");
But that will (for some reason) parse it as a list of one entry. So to get the value, you need
String fooValue= (String)namespace.getList("foo").get(0);