Skip to content

Commit

Permalink
Add --expand-context options (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
filip26 committed Jul 30, 2024
1 parent e423ebb commit 30a5db7
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/main/java/com/apicatalog/cli/command/FlattenCmd.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import com.apicatalog.cli.JsonOutput;
import com.apicatalog.jsonld.JsonLd;
import com.apicatalog.jsonld.JsonLdOptions;
import com.apicatalog.jsonld.JsonLdVersion;
import com.apicatalog.jsonld.api.FlatteningApi;
import com.apicatalog.jsonld.document.JsonDocument;
Expand Down Expand Up @@ -35,9 +36,12 @@ public final class FlattenCmd implements Callable<Integer> {
@Option(names = { "-i", "--input" }, description = "input document IRI")
URI input = null;

@Option(names = { "-c", "--context" }, description = "context IRI")
@Option(names = { "-c", "--context" }, description = "context IRI to compact the flattened document")
URI context = null;

@Option(names = { "-e", "--expand-context" }, description = "context IRI to expand the document before flattening")
URI expandContext = null;

@Option(names = { "-b", "--base" }, description = "input document base IRI")
URI base = null;

Expand Down Expand Up @@ -67,6 +71,11 @@ public Integer call() throws Exception {
} else {
api = JsonLd.flatten(JsonDocument.of(System.in));
}

final JsonLdOptions options = new JsonLdOptions();
options.setExpandContext(expandContext);

api.options(options);

if (mode != null) {
api.mode(JsonLdVersion.of("json-ld-" + mode));
Expand Down

0 comments on commit 30a5db7

Please sign in to comment.