From 1fc8aa20e07bfbc3bcde4740c31c0933aed9e65e Mon Sep 17 00:00:00 2001 From: Matt Muller Date: Tue, 14 Jan 2025 18:52:14 -0500 Subject: [PATCH] Support include-prelude in smithy ast --- .../amazon/smithy/cli/commands/AstCommand.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/smithy-cli/src/main/java/software/amazon/smithy/cli/commands/AstCommand.java b/smithy-cli/src/main/java/software/amazon/smithy/cli/commands/AstCommand.java index e78c8f988bb..fcece08e964 100644 --- a/smithy-cli/src/main/java/software/amazon/smithy/cli/commands/AstCommand.java +++ b/smithy-cli/src/main/java/software/amazon/smithy/cli/commands/AstCommand.java @@ -54,18 +54,26 @@ private static final class Options implements ArgumentReceiver { static final String FLATTEN_OPTION = "--flatten"; private boolean flatten = false; + static final String INCLUDE_PRELUDE_OPTION = "--include-prelude"; + private boolean includePrelude = false; + @Override public boolean testOption(String name) { if (FLATTEN_OPTION.equals(name)) { flatten = true; return true; } + if (INCLUDE_PRELUDE_OPTION.equals(name)) { + includePrelude = true; + return true; + } return false; } @Override public void registerHelp(HelpPrinter printer) { printer.option(FLATTEN_OPTION, null, "Flattens and removes mixins from the model."); + printer.option(INCLUDE_PRELUDE_OPTION, null, "Includes the prelude shapes in the model."); } } @@ -80,8 +88,8 @@ private int runWithClassLoader(SmithyBuildConfig config, Arguments arguments, En .defaultSeverity(Severity.DANGER) .build(); - ModelSerializer serializer = ModelSerializer.builder().build(); Options options = arguments.getReceiver(Options.class); + ModelSerializer serializer = ModelSerializer.builder().includePrelude(options.includePrelude).build(); if (options.flatten) { model = ModelTransformer.create().flattenAndRemoveMixins(model); }