Skip to content

Commit c5f3de1

Browse files
authored
Merge pull request #48 from openjavaformat/dry-run-replace-message
Name --replace in the error for --dry-run with in-place formatting
2 parents 67c0111 + c73a083 commit c5f3de1

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

‎open-java-format/src/main/java/com/palantir/javaformat/java/Main.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ public static CommandLineOptions processArgs(String... args) throws UsageExcepti
273273
throw new UsageException("--assume-filename is only supported when formatting standard input");
274274
}
275275
if (parameters.dryRun() && parameters.inPlace()) {
276-
throw new UsageException("cannot use --dry-run and --in-place at the same time");
276+
throw new UsageException("cannot use --dry-run and --replace at the same time");
277277
}
278278
return parameters;
279279
}

‎open-java-format/src/test/java/com/palantir/javaformat/java/CommandLineFlagsTest.java‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,18 @@ public void inPlaceStdin() {
102102

103103
@Test
104104
public void inPlaceDryRun() {
105+
try {
106+
Main.processArgs("--replace", "--dry-run", "A.java");
107+
fail("fail");
108+
} catch (UsageException e) {
109+
assertThat(e).hasMessageThat().contains("cannot use --dry-run and --replace at the same time");
110+
}
111+
105112
try {
106113
Main.processArgs("-i", "-n", "A.java");
107114
fail("fail");
108115
} catch (UsageException e) {
109-
assertThat(e).hasMessageThat().contains("cannot use --dry-run and --in-place at the same time");
116+
assertThat(e).hasMessageThat().contains("cannot use --dry-run and --replace at the same time");
110117
}
111118
}
112119

0 commit comments

Comments
 (0)