Skip to content

Commit b103dfc

Browse files
committed
Another improvement for --out-format
1 parent 5c45360 commit b103dfc

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

rdf-processing-toolkit-cli/src/main/java/org/aksw/sparql_integrate/cli/main/SparqlIntegrateCmdImpls.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,14 +244,23 @@ public static int sparqlIntegrate(CmdSparqlIntegrateMain cmd) throws Exception {
244244

245245
// If a format is given it takes precedence - otherwise try to use the filename
246246
String outFormat = cmd.outFormat;
247+
248+
// Format source can be either a filename "foo.nt", a file extension "ttl" or a format string "turtle/pretty"
247249
String formatSource = outFormat == null
248250
? outFilename
249251
: outFormat;
250252

251-
if (outFormat == null && formatSource != null) {
253+
// Try to parse the format source as a file name or file extension
254+
if (formatSource != null) {
252255
// Try to derive the outFormat from the filename - if given.
253256
FileName fn = fileNameParser.parse(formatSource);
254-
outFormat = fn.getContentPart();
257+
String tmpOutFormat = fn.getContentPart();
258+
259+
// Replace the outFormat with the result of the successful parse
260+
if (tmpOutFormat != null) {
261+
outFormat = tmpOutFormat;
262+
}
263+
255264
rawOutEncodings.addAll(fn.getEncodingParts());
256265
}
257266

0 commit comments

Comments
 (0)