Skip to content

Commit 19305f9

Browse files
committed
Make the outputformat default value natively integrated to joptsimple
1 parent accb424 commit 19305f9

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

tools/src/main/java/com/github/jsonldjava/tools/Playground.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ public Class<RDFFormat> valueType() {
9696
return RDFFormat.class;
9797
}
9898
})
99+
.defaultsTo(RDFFormat.NQUADS)
99100
.describedAs(
100101
"The output file format to use. Defaults to nquads. Valid values are: "
101102
+ formats.keySet());
@@ -181,8 +182,7 @@ public Class<String> valueType() {
181182
opts.outputForm = options.valueOf(outputForm);
182183
opts.format = options.has(outputFormat) ? options.valueOf(outputFormat)
183184
.getDefaultMIMEType() : "application/nquads";
184-
final RDFFormat sesameOutputFormat = options.has(outputFormat) ? options
185-
.valueOf(outputFormat) : RDFFormat.NQUADS;
185+
final RDFFormat sesameOutputFormat = options.valueOf(outputFormat);
186186
final RDFFormat sesameInputFormat = Rio.getParserFormatForFileName(
187187
options.valueOf(inputFile).getName(), RDFFormat.JSONLD);
188188

@@ -223,9 +223,10 @@ public Class<String> valueType() {
223223
outobj = JsonLdProcessor.fromRDF(inModel, opts, new SesameJSONLDRDFParser());
224224
} else if ("tordf".equals(processingOptionValue)) {
225225
opts.useNamespaces = true;
226-
outobj = JsonLdProcessor.toRDF(inobj,
227-
new SesameJSONLDTripleCallback(Rio.createWriter(sesameOutputFormat, System.out)),
228-
opts);
226+
outobj = JsonLdProcessor
227+
.toRDF(inobj,
228+
new SesameJSONLDTripleCallback(Rio.createWriter(sesameOutputFormat,
229+
System.out)), opts);
229230
} else if ("expand".equals(processingOptionValue)) {
230231
outobj = JsonLdProcessor.expand(inobj, opts);
231232
} else if ("compact".equals(processingOptionValue)) {
@@ -240,7 +241,7 @@ public Class<String> valueType() {
240241
} else if ("frame".equals(processingOptionValue)) {
241242
if (ctxobj != null && !(ctxobj instanceof Map)) {
242243
System.out
243-
.println("Invalid JSON-LD syntax; a JSON-LD frame must be a single object.");
244+
.println("Invalid JSON-LD syntax; a JSON-LD frame must be a single object.");
244245
parser.printHelpOn(System.out);
245246
return;
246247
}

0 commit comments

Comments
 (0)