}
private static Options buildOptions() {
Options opts = new Options();
Option help = new Option("h", "help", false,
"Print help for the Rat command line interface and exit");
opts.addOption(help);
OptionGroup addLicenceGroup = new OptionGroup();
String addLicenceDesc = "Add the default licence header to any file with an unknown licence that is not in the exclusion list. By default new files will be created with the licence header, to force the modification of existing files use the --force option.";
Option addLicence = new Option(
"a",
"addLicence",
false,
addLicenceDesc);
addLicenceGroup.addOption(addLicence);
Option addLicense = new Option(
"A",
"addLicense",
false,
addLicenceDesc);
addLicenceGroup.addOption(addLicense);
opts.addOptionGroup(addLicenceGroup);
Option write = new Option(
"f",
"force",
false,
"Forces any changes in files to be written directly to the source files (i.e. new files are not created)");
opts.addOption(write);
Option copyright = new Option(
"c",
"copyright",
true,
"The copyright message to use in the licence headers, usually in the form of \"Copyright 2008 Foo\"");
opts.addOption(copyright);
final Option exclude = OptionBuilder
.withArgName("expression")
.withLongOpt("exclude")
.hasArgs()
.withDescription("Excludes files matching wildcard <expression>. " +
"Note that --dir is required when using this parameter. " +
"Allows multiple arguments.")
.create(EXCLUDE_CLI);
opts.addOption(exclude);
final Option excludeFile = OptionBuilder
.withArgName("fileName")
.withLongOpt("exclude-file")
.hasArgs()
.withDescription("Excludes files matching regular expression in <file> " +
"Note that --dir is required when using this parameter. " )
.create(EXCLUDE_FILE_CLI);
opts.addOption(excludeFile);
Option dir = new Option(
"d",
"dir",
false,
"Used to indicate source when using --exclude");
opts.addOption(dir);
OptionGroup outputType = new OptionGroup();
Option xml = new Option(
"x",
"xml",
false,
"Output the report in raw XML format. Not compatible with -s");
outputType.addOption(xml);
Option xslt = new Option(String.valueOf(STYLESHEET_CLI),
"stylesheet",
true,
"XSLT stylesheet to use when creating the"
+ " report. Not compatible with -x");
outputType.addOption(xslt);