The --default parameter will load up the argument when the user does not specify the argument on the command-line.
This example will run MyProgram
with the value "IBM" for --ticker
.
CmdLine.create("--type string --key ticker --default IBM");
> MyProgram
Notice the short names used for most of the parameters.
If you specify --multiple
as a parameter then the default can be more than one value. This example would load the --ticker
argument with "IBM" and "GOOG".
CmdLine.create("-t string -k ticker -m 1 10 --default IBM GOOG");
> MyProgram
If the user enters a value for --ticker
then the defaults are not applied at all. In this example the --ticker
argument would be loaded with "MSFT" only.
CmdLine.create("-t string -k ticker -m 1 10 --default IBM GOOG");
> MyProgram --ticker MSFT