use of io.cucumber.core.feature.GluePath in project cucumber-jvm by cucumber.
the class CommandlineOptionsParser method parse.
private RuntimeOptionsBuilder parse(List<String> args) {
args = new ArrayList<>(args);
RuntimeOptionsBuilder parsedOptions = new RuntimeOptionsBuilder();
while (!args.isEmpty()) {
String arg = args.remove(0).trim();
if (arg.equals(HELP) || arg.equals(HELP_SHORT)) {
printUsage();
exitCode = 0;
return parsedOptions;
} else if (arg.equals(VERSION) || arg.equals(VERSION_SHORT)) {
out.println(CORE_VERSION);
exitCode = 0;
return parsedOptions;
} else if (arg.equals(I18N)) {
String nextArg = removeArgFor(arg, args);
exitCode = printI18n(nextArg);
return parsedOptions;
} else if (arg.equals(THREADS)) {
int threads = Integer.parseInt(removeArgFor(arg, args));
if (threads < 1) {
out.println("--threads must be > 0");
exitCode = 1;
return parsedOptions;
}
parsedOptions.setThreads(threads);
} else if (arg.equals(GLUE) || arg.equals(GLUE_SHORT)) {
String gluePath = removeArgFor(arg, args);
URI parse = GluePath.parse(gluePath);
parsedOptions.addGlue(parse);
} else if (arg.equals(TAGS) || arg.equals(TAGS_SHORT)) {
parsedOptions.addTagFilter(TagExpressionParser.parse(removeArgFor(arg, args)));
} else if (arg.equals(PUBLISH)) {
parsedOptions.setPublish(true);
} else if (arg.equals(PLUGIN) || arg.equals(PLUGIN_SHORT)) {
String pluginName = removeArgFor(arg, args);
if (pluginName.equals("null_summary")) {
log.warn(() -> "Use '--no-summary' instead of '-p/--plugin null_summary'. '-p/--plugin null_summary' will be removed in a future release.");
parsedOptions.setNoSummary();
} else if (pluginName.equals("default_summary")) {
log.warn(() -> "Use '-p/--plugin summary' instead of '-p/--plugin default_summary'. '-p/--plugin default_summary' will be removed in a future release.");
parsedOptions.addPluginName("summary");
} else {
parsedOptions.addPluginName(pluginName);
}
} else if (arg.equals(DRY_RUN) || arg.equals(DRY_RUN_SHORT)) {
parsedOptions.setDryRun(true);
} else if (arg.equals(NO_DRY_RUN)) {
parsedOptions.setDryRun(false);
} else if (arg.equals(NO_SUMMARY)) {
parsedOptions.setNoSummary();
} else if (arg.equals(MONOCHROME) || arg.equals(MONOCHROME_SHORT)) {
parsedOptions.setMonochrome(true);
} else if (arg.equals(NO_MONOCHROME)) {
parsedOptions.setMonochrome(false);
} else if (arg.equals(SNIPPETS)) {
String nextArg = removeArgFor(arg, args);
parsedOptions.setSnippetType(SnippetTypeParser.parseSnippetType(nextArg));
} else if (arg.equals(NAME) || arg.equals(NAME_SHORT)) {
String nextArg = removeArgFor(arg, args);
Pattern pattern = Pattern.compile(nextArg);
parsedOptions.addNameFilter(pattern);
} else if (arg.equals(WIP) || arg.equals(WIP_SHORT)) {
parsedOptions.setWip(true);
} else if (arg.equals(ORDER)) {
parsedOptions.setPickleOrder(PickleOrderParser.parse(removeArgFor(arg, args)));
} else if (arg.equals(COUNT)) {
int count = Integer.parseInt(removeArgFor(arg, args));
if (count < 1) {
out.println("--count must be > 0");
exitCode = 1;
return parsedOptions;
}
parsedOptions.setCount(count);
} else if (arg.equals(OBJECT_FACTORY)) {
String objectFactoryClassName = removeArgFor(arg, args);
parsedOptions.setObjectFactoryClass(parseObjectFactory(objectFactoryClassName));
} else if (arg.startsWith("-")) {
out.println("Unknown option: " + arg);
printUsage();
exitCode = 1;
return parsedOptions;
} else if (!arg.isEmpty()) {
if (arg.startsWith("@")) {
Path rerunFile = Paths.get(arg.substring(1));
parsedOptions.addRerun(parseFeatureWithLinesFile(rerunFile));
} else {
FeatureWithLines featureWithLines = FeatureWithLines.parse(arg);
parsedOptions.addFeature(featureWithLines);
}
}
}
return parsedOptions;
}
Aggregations