Skip to content

Commit

Permalink
Add short --aut for --allow-unknown-traits
Browse files Browse the repository at this point in the history
  • Loading branch information
mtdowling committed Aug 25, 2023
1 parent 302ace8 commit 93ffafd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
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

0 comments on commit 93ffafd

Please sign in to comment.