Skip to content
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 @@ -71,6 +71,7 @@ static CommandLineOptions parse(Iterable<String> options) {
parseRangeSet(linesBuilder, getValue(flag, it, value));
case "--offset", "-offset" -> optionsBuilder.addOffset(parseInteger(it, flag, value));
case "--length", "-length" -> optionsBuilder.addLength(parseInteger(it, flag, value));
case "--google-style", "-google-style" -> optionsBuilder.aosp(false);
case "--aosp", "-aosp", "-a" -> optionsBuilder.aosp(true);
case "--version", "-version", "-v" -> optionsBuilder.version(true);
case "--help", "-help", "-h" -> optionsBuilder.help(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ final class UsageException extends Exception {
Format stdin -> stdout
--assume-filename, -assume-filename
File name to use for diagnostics when formatting standard input (default is <stdin>).
--google-style, -google-style
Use Google Style (2-space indentation). This is the default; if both --aosp and
--google-style are given, the last one wins.
--aosp, -aosp, -a
Use AOSP style instead of Google Style (4-space indentation).
--fix-imports-only
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,20 @@ public void aosp() {
assertThat(CommandLineOptionsParser.parse(Arrays.asList("-aosp")).aosp()).isTrue();
}

@Test
public void googleStyle() {
assertThat(CommandLineOptionsParser.parse(Arrays.asList("--google-style")).aosp()).isFalse();
assertThat(CommandLineOptionsParser.parse(Arrays.asList("-google-style")).aosp()).isFalse();
}

@Test
public void lastStyleWins() {
assertThat(CommandLineOptionsParser.parse(Arrays.asList("--aosp", "--google-style")).aosp())
.isFalse();
assertThat(CommandLineOptionsParser.parse(Arrays.asList("--google-style", "--aosp")).aosp())
.isTrue();
}

@Test
public void help() {
assertThat(CommandLineOptionsParser.parse(Arrays.asList("-help")).help()).isTrue();
Expand Down
Loading