Skip to content

Commit

Permalink
Add some more makeup
Browse files Browse the repository at this point in the history
  • Loading branch information
cstamas committed Sep 17, 2024
1 parent 9bea2ee commit 7b69eb5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import java.util.Objects;
import java.util.Properties;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.function.Predicate;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -754,7 +755,22 @@ public Result<Map<Artifact, Boolean>> exists(
} else {
existingOnes.add(artifact);
}
output.tell("Artifact {} {}", artifact, exists ? "EXISTS" : "NOT EXISTS");

BiConsumer<Artifact, Boolean> reporter = (a, e) -> {
if (e) {
output.marker(Output.Verbosity.NORMAL)
.normal("Artifact {} ")
.outstanding("EXISTS")
.say(a);
} else {
output.marker(Output.Verbosity.NORMAL)
.normal("Artifact {} ")
.scary("NOT EXISTS")
.say(a);
}
};

reporter.accept(artifact, exists);
if (pom && !"pom".equals(artifact.getExtension())) {
Artifact poma = new SubArtifact(artifact, null, "pom");
exists = toolboxSearchApi.exists(backend, poma);
Expand All @@ -764,7 +780,7 @@ public Result<Map<Artifact, Boolean>> exists(
} else if (allRequired) {
existingOnes.add(poma);
}
output.tell(" {} {}", poma, exists ? "EXISTS" : "NOT EXISTS");
reporter.accept(poma, exists);
}
if (sources) {
Artifact sourcesa = new SubArtifact(artifact, "sources", "jar");
Expand All @@ -775,7 +791,7 @@ public Result<Map<Artifact, Boolean>> exists(
} else if (allRequired) {
existingOnes.add(sourcesa);
}
output.tell(" {} {}", sourcesa, exists ? "EXISTS" : "NOT EXISTS");
reporter.accept(sourcesa, exists);
}
if (javadoc) {
Artifact javadoca = new SubArtifact(artifact, "javadoc", "jar");
Expand All @@ -786,7 +802,7 @@ public Result<Map<Artifact, Boolean>> exists(
} else if (allRequired) {
existingOnes.add(javadoca);
}
output.tell(" {} {}", javadoca, exists ? "EXISTS" : "NOT EXISTS");
reporter.accept(javadoca, exists);
}
if (signature) {
Artifact signaturea = new SubArtifact(artifact, null, artifact.getExtension() + ".asc");
Expand All @@ -797,15 +813,13 @@ public Result<Map<Artifact, Boolean>> exists(
} else if (allRequired) {
existingOnes.add(signaturea);
}
output.tell(" {} {}", signaturea, exists ? "EXISTS" : "NOT EXISTS");
reporter.accept(signaturea, exists);
}
}
output.tell("");
output.tell(
"Checked TOTAL of {} (existing: {} not existing: {})",
existingOnes.size() + missingOnes.size(),
existingOnes.size(),
missingOnes.size());
output.marker(Output.Verbosity.TIGHT)
.emphasize("Checked TOTAL of {} (existing: {} not existing: {})")
.say(existingOnes.size() + missingOnes.size(), existingOnes.size(), missingOnes.size());
return missingOnes.isEmpty() ? Result.success(result) : Result.failure("Missing artifacts");
}

Expand Down Expand Up @@ -844,15 +858,17 @@ public Result<Map<String, Artifact>> identify(

sha1s.forEach((key, value) -> {
Artifact a = result.get(value);
String hit = a != null ? a.toString() : "Unknown";
String hit = a != null ? a.toString() : "UNKNOWN";
if (decorated) {
if (!Objects.equals(key, value)) {
output.tell("{} ({}) = {}", value, key, hit);
output.marker(Output.Verbosity.TIGHT)
.outstanding("{} ({}) = {}")
.say(value, key, hit);
} else {
output.tell("{} = {}", value, hit);
output.marker(Output.Verbosity.TIGHT).outstanding("{} = {}").say(value, hit);
}
} else {
output.tell(hit);
output.marker(Output.Verbosity.TIGHT).outstanding(hit).say();
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ public Map<String, Artifact> identify(
RepositorySystemSession session, SearchBackend searchBackend, Collection<String> sha1s) throws IOException {
HashMap<String, Artifact> result = new HashMap<>(sha1s.size());
for (String sha1 : sha1s) {
output.tell("Identifying artifact with SHA1={}", sha1);
output.suggest("Identifying artifact with SHA1={}", sha1);
SearchRequest searchRequest = new SearchRequest(fieldQuery(MAVEN.SHA1, sha1));
SearchResponse searchResponse = searchBackend.search(searchRequest);
output.chatter(
Expand Down

0 comments on commit 7b69eb5

Please sign in to comment.