Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add short --aut for --allow-unknown-traits #1950

Merged
merged 1 commit into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
final class BuildOptions implements ArgumentReceiver {

static final String ALLOW_UNKNOWN_TRAITS = "--allow-unknown-traits";
static final String ALLOW_UNKNOWN_TRAITS_SHORT = "--aut";
static final String MODELS = "<MODELS>";

private boolean allowUnknownTraits;
Expand All @@ -37,7 +38,8 @@ final class BuildOptions implements ArgumentReceiver {

@Override
public void registerHelp(HelpPrinter printer) {
printer.option(ALLOW_UNKNOWN_TRAITS, null, "Ignore unknown traits when validating models.");
printer.option(ALLOW_UNKNOWN_TRAITS, ALLOW_UNKNOWN_TRAITS_SHORT,
"Ignore unknown traits when validating models.");
printer.param("--output", null, "OUTPUT_PATH",
"Where to write Smithy artifacts, caches, and other files (defaults to './build/smithy').");

Expand All @@ -48,7 +50,7 @@ public void registerHelp(HelpPrinter printer) {

@Override
public boolean testOption(String name) {
if (ALLOW_UNKNOWN_TRAITS.equals(name)) {
if (ALLOW_UNKNOWN_TRAITS.equals(name) || ALLOW_UNKNOWN_TRAITS_SHORT.equalsIgnoreCase(name)) {
allowUnknownTraits = true;
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ public void projectionUnknownTraitsAreAllowedWithFlag() throws Exception {
assertThat(result.stderr(), containsString("Smithy built "));
}

@Test
public void projectionUnknownTraitsAreAllowedWithShortFlag() throws Exception {
String config = Paths.get(getClass().getResource("projection-model-import.json").toURI()).toString();
CliUtils.Result result = CliUtils.runSmithy("build", "--aut", "--config", config);

assertThat(result.code(), equalTo(0));
}

@Test
public void exceptionsThrownByProjectionsAreDetected() {
// TODO: need to make a plugin throw an exception
Expand Down