Skip to content

Commit

Permalink
Remove non-flag arguments.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 256009064
  • Loading branch information
kendalllaneee authored and copybara-github committed Jul 1, 2019
1 parent e6ab3c4 commit 2e374a9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 26 deletions.
1 change: 0 additions & 1 deletion src/main/java/com/google/devtools/build/skydoc/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,5 @@ java_library(
"//src/main/java/com/google/devtools/build/skydoc/rendering/proto:stardoc_output_java_proto",
"//src/main/java/com/google/devtools/common/options",
"//third_party:guava",
"//third_party:jsr305",
],
)
31 changes: 6 additions & 25 deletions src/main/java/com/google/devtools/build/skydoc/SkydocMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,27 +193,16 @@ public static void main(String[] args)
ImmutableSet<String> symbolNames;
ImmutableList<String> depRoots;

// TODO(cparsons): Remove optional positional arg parsing.
List<String> residualArgs = parser.getResidue();
if (Strings.isNullOrEmpty(skydocOptions.targetFileLabel)
|| Strings.isNullOrEmpty(skydocOptions.outputFilePath)) {
if (residualArgs.size() < 2) {
throw new IllegalArgumentException(
"Expected two or more arguments. Usage:\n"
+ "{skydoc_bin} {target_skylark_file_label} {output_file} [symbol_names]...");
}

targetFileLabelString = residualArgs.get(0);
outputPath = residualArgs.get(1);
symbolNames = getSymbolNames(residualArgs);
depRoots = ImmutableList.of();
} else {
targetFileLabelString = skydocOptions.targetFileLabel;
outputPath = skydocOptions.outputFilePath;
symbolNames = ImmutableSet.copyOf(skydocOptions.symbolNames);
depRoots = ImmutableList.copyOf(skydocOptions.depRoots);
throw new IllegalArgumentException("Expected a target file label and an output file path.");
}

targetFileLabelString = skydocOptions.targetFileLabel;
outputPath = skydocOptions.outputFilePath;
symbolNames = ImmutableSet.copyOf(skydocOptions.symbolNames);
depRoots = ImmutableList.copyOf(skydocOptions.depRoots);

Label targetFileLabel = Label.parseAbsolute(targetFileLabelString, ImmutableMap.of());

ImmutableMap.Builder<String, RuleInfo> ruleInfoMap = ImmutableMap.builder();
Expand Down Expand Up @@ -278,14 +267,6 @@ private static boolean validSymbolName(ImmutableSet<String> symbolNames, String
return false;
}

private static ImmutableSet<String> getSymbolNames(List<String> args) {
ImmutableSet.Builder<String> symbolNameSet = ImmutableSet.builder();
for (int argi = 2; argi < args.size(); argi++) {
symbolNameSet.add(args.get(argi));
}
return symbolNameSet.build();
}

private static void printRuleInfos(
PrintWriter printWriter, MarkdownRenderer renderer, Map<String, RuleInfo> ruleInfos)
throws IOException {
Expand Down

0 comments on commit 2e374a9

Please sign in to comment.