Skip to content

Commit 2bd0b35

Browse files
author
Loïc GREFFIER
authored
Displayed message when no resource to display (#197)
* Migrate schemas get all to reactive * Retrieve all information on get all * Fix some Sonar * Fix unit tests * Display a message when there is no resource to display
1 parent 3bf6efc commit 2bd0b35

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

cli/src/main/java/com/michelin/ns4kafka/cli/DeleteSubcommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public Integer call() {
164164
.findFirst()
165165
.orElseThrow();
166166
boolean success = resourceService.delete(apiResource, namespace, resource.getMetadata().getName(), dryRun);
167-
if(success) {
167+
if (success) {
168168
System.out.println(CommandLine.Help.Ansi.AUTO.string("@|bold,green Success |@") + apiResource.getKind() + "/" + resource.getMetadata().getName() + " (deleted)");
169169
}
170170
return success;

cli/src/main/java/com/michelin/ns4kafka/cli/GetSubcommand.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,16 @@ public Integer call() throws Exception {
126126
try {
127127
// List all resources for given types (k get all, k get topics)
128128
Map<ApiResource, List<Resource>> resources = resourceService.listAll(apiResources, namespace);
129-
// Display all resources by type
130-
resources.entrySet()
131-
.stream()
132-
.filter(kv -> !kv.getValue().isEmpty())
133-
.forEach(kv -> formatService.displayList(kv.getKey().getKind(), kv.getValue(), output));
129+
130+
if (resources.entrySet().size() == 1 && resources.get(resources.keySet().iterator().next()).isEmpty()) {
131+
System.out.println("No resource to display.");
132+
} else {
133+
// Display all resources by type
134+
resources.entrySet()
135+
.stream()
136+
.filter(kv -> !kv.getValue().isEmpty())
137+
.forEach(kv -> formatService.displayList(kv.getKey().getKind(), kv.getValue(), output));
138+
}
134139
} catch (HttpClientResponseException e) {
135140
formatService.displayError(e, apiResources.get(0).getKind(), null);
136141
} catch (Exception e) {

0 commit comments

Comments
 (0)