From 9f449aa5c54a031b8a36124e02fe538c68aaa746 Mon Sep 17 00:00:00 2001 From: David Waltermire Date: Wed, 11 Dec 2024 10:38:53 -0500 Subject: [PATCH] Added the --relative-to=URI argument to the resolve command to support relative generated links during profile resolution. Resolves #84. (#88) --- .../core/commands/AbstractResolveCommand.java | 28 +++++++++++++++++-- .../commands/ListAllowedValuesCommand.java | 2 +- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/main/java/gov/nist/secauto/oscal/tools/cli/core/commands/AbstractResolveCommand.java b/src/main/java/gov/nist/secauto/oscal/tools/cli/core/commands/AbstractResolveCommand.java index f4bfbbe..dec2609 100644 --- a/src/main/java/gov/nist/secauto/oscal/tools/cli/core/commands/AbstractResolveCommand.java +++ b/src/main/java/gov/nist/secauto/oscal/tools/cli/core/commands/AbstractResolveCommand.java @@ -16,6 +16,7 @@ import gov.nist.secauto.metaschema.core.metapath.item.node.IDocumentNodeItem; import gov.nist.secauto.metaschema.core.metapath.item.node.INodeItem; import gov.nist.secauto.metaschema.core.util.ObjectUtils; +import gov.nist.secauto.metaschema.core.util.UriUtils; import gov.nist.secauto.metaschema.databind.IBindingContext; import gov.nist.secauto.metaschema.databind.io.DeserializationFeature; import gov.nist.secauto.metaschema.databind.io.Format; @@ -33,6 +34,7 @@ import java.io.IOException; import java.io.PrintStream; import java.net.URI; +import java.net.URISyntaxException; import java.nio.file.Path; import java.util.Collection; import java.util.List; @@ -48,12 +50,19 @@ public abstract class AbstractResolveCommand private static final List EXTRA_ARGUMENTS = ObjectUtils.notNull(List.of( ExtraArgument.newInstance("URI to resolve", true), ExtraArgument.newInstance("destination file", false))); + private static final Option RELATIVE_TO = Option.builder() + .longOpt("relative-to") + .desc("Generate URI references relative to this resource") + .hasArg() + .build(); + @NonNull private static final List