|
|
@@ -1,5 +1,6 @@
|
|
|
package jplag;
|
|
|
|
|
|
+import static jplag.strategy.ComparisonMode.NORMAL;
|
|
|
import static net.sourceforge.argparse4j.impl.Arguments.storeTrue;
|
|
|
|
|
|
import java.io.File;
|
|
|
@@ -8,6 +9,7 @@ import jplag.options.JPlagOptions;
|
|
|
import jplag.options.LanguageOption;
|
|
|
import jplag.options.Verbosity;
|
|
|
import jplag.reporting.Report;
|
|
|
+import jplag.strategy.ComparisonMode;
|
|
|
import net.sourceforge.argparse4j.ArgumentParsers;
|
|
|
import net.sourceforge.argparse4j.inf.ArgumentParser;
|
|
|
import net.sourceforge.argparse4j.inf.ArgumentParserException;
|
|
|
@@ -15,7 +17,6 @@ import net.sourceforge.argparse4j.inf.Namespace;
|
|
|
|
|
|
/**
|
|
|
* Command line interface class, allows using via command line.
|
|
|
- *
|
|
|
* @see CLI#main(String[])
|
|
|
*/
|
|
|
public class CLI {
|
|
|
@@ -30,7 +31,6 @@ public class CLI {
|
|
|
|
|
|
/**
|
|
|
* Main class for using JPlag via the CLI.
|
|
|
- *
|
|
|
* @param args are the CLI arguments that will be passed to JPlag.
|
|
|
*/
|
|
|
public static void main(String[] args) {
|
|
|
@@ -58,9 +58,7 @@ public class CLI {
|
|
|
|
|
|
// TODO SH: Fix code duplication of CLI arguments
|
|
|
parser.addArgument("rootDir").help("The root-directory that contains all submissions");
|
|
|
- parser.addArgument("-l")
|
|
|
- .choices(LanguageOption.getAllDisplayNames())
|
|
|
- .setDefault(LanguageOption.getDefault().getDisplayName())
|
|
|
+ parser.addArgument("-l").choices(LanguageOption.getAllDisplayNames()).setDefault(LanguageOption.getDefault().getDisplayName())
|
|
|
.help("Select the language to parse the submissions");
|
|
|
parser.addArgument("-bc").help("Name of the directory which contains the base code (common framework)");
|
|
|
parser.addArgument("-v").choices(verbosityOptions).setDefault("quiet").help("Verbosity");
|
|
|
@@ -71,11 +69,11 @@ public class CLI {
|
|
|
parser.addArgument("-t").help("Tune the sensitivity of the comparison. A smaller <n> increases the sensitivity");
|
|
|
parser.addArgument("-m").setDefault(0f).help("Match similarity Threshold [0-100]: All matches above this threshold will be saved");
|
|
|
parser.addArgument("-r").setDefault("result").help("Name of directory in which the comparison results will be stored");
|
|
|
+ parser.addArgument("-c").choices(ComparisonMode.allNames()).setDefault(NORMAL.getName()).help("Comparison mode used to compare the programs");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Parses an array of argument strings.
|
|
|
- *
|
|
|
* @param args is the array to parse.
|
|
|
* @return the parsed arguments in a {@link Namespace} format.
|
|
|
*/
|
|
|
@@ -91,13 +89,12 @@ public class CLI {
|
|
|
|
|
|
/**
|
|
|
* Builds a options instance from parsed arguments.
|
|
|
- *
|
|
|
* @param namespace encapsulates the parsed arguments in a {@link Namespace} format.
|
|
|
* @return the newly built options.F
|
|
|
*/
|
|
|
public JPlagOptions buildOptionsFromArguments(Namespace namespace) {
|
|
|
String fileSuffixString = namespace.getString("p");
|
|
|
- String[] fileSuffixes = new String[]{};
|
|
|
+ String[] fileSuffixes = new String[] {};
|
|
|
if (fileSuffixString != null) {
|
|
|
fileSuffixes = fileSuffixString.replaceAll("\\s+", "").split(",");
|
|
|
}
|
|
|
@@ -111,6 +108,8 @@ public class CLI {
|
|
|
options.setSubdirectoryName(namespace.getString("S"));
|
|
|
options.setFileSuffixes(fileSuffixes);
|
|
|
options.setExclusionFileName(namespace.getString("x"));
|
|
|
+ ComparisonMode.fromName(namespace.getString("c")).ifPresentOrElse(it -> options.setComparisonMode(it),
|
|
|
+ () -> System.out.println("Unknown comparison mode, using default"));
|
|
|
|
|
|
String minTokenMatch = namespace.getString("t");
|
|
|
if (minTokenMatch != null) {
|