Commit 6f073c97 authored by 王品堯's avatar 王品堯

增加參數的判斷

parent 1db7e5c2
...@@ -19,12 +19,15 @@ public class LanguageFileCompare { ...@@ -19,12 +19,15 @@ public class LanguageFileCompare {
public static void main(String[] args) { public static void main(String[] args) {
try { try {
ObjectMapper objectMapper = new ObjectMapper(); ObjectMapper objectMapper = new ObjectMapper();
Path originPath = Paths.get(args[0]); if (args.length > 0) {
JsonNode twJson = objectMapper.readTree(new String(Files.readAllBytes(originPath))); Path originPath = Paths.get(args[0]);
Set<String> originSet = new HashSet<>(); JsonNode twJson = objectMapper.readTree(new String(Files.readAllBytes(originPath)));
addKeys("", twJson, originSet, new ArrayList<>()); Set<String> originSet = new HashSet<>();
addKeys("", twJson, originSet, new ArrayList<>());
IntStream.range(1, args.length).forEach(i -> findMissingKeys(Paths.get(args[i]), originSet)); IntStream.range(1, args.length)
.forEach(i -> findMissingKeys(Paths.get(args[i]), originSet));
}
} catch (Exception e) { } catch (Exception e) {
log.error("{} is not exists or not json files.", args[0], e); log.error("{} is not exists or not json files.", args[0], e);
System.exit(1); System.exit(1);
...@@ -87,9 +90,9 @@ public class LanguageFileCompare { ...@@ -87,9 +90,9 @@ public class LanguageFileCompare {
Map<String, List<String>> map = Map<String, List<String>> map =
Arrays.stream( Arrays.stream(
Optional.ofNullable( Optional.ofNullable(
Paths.get(path).toFile().list((dir, name) -> name.endsWith(extension))) Paths.get(path).toFile().list((dir, name) -> name.endsWith(extension)))
.orElse(new String[0])) .orElse(new String[0]))
.map(s -> s.split(extension)[0]) .map(s -> s.split(extension)[0])
.collect( .collect(
Collectors.groupingBy( Collectors.groupingBy(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment