Skip to content

Commit

Permalink
[Minor] Updates to delete multiple tags in Gravitino CLI (apache#5666)
Browse files Browse the repository at this point in the history
### What changes were proposed in this pull request?

Fixed some display issues and minor improvements to code.

### Why are the changes needed?

To have display messages more consistent.

Fix: # N/A

### Does this PR introduce _any_ user-facing change?

N/A
### How was this patch tested?

Tested locally.

---------

Co-authored-by: sunxiaojian <[email protected]>
  • Loading branch information
justinmclean and sunxiaojian authored Nov 26, 2024
1 parent 4dd0440 commit f902f2f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,9 @@ protected void handleTagCommand() {
String metalake = name.getMetalakeName();

String[] tags = line.getOptionValues(GravitinoOptions.TAG);
tags = tags != null ? Arrays.stream(tags).distinct().toArray(String[]::new) : null;
if (tags != null) {
tags = Arrays.stream(tags).distinct().toArray(String[]::new);
}
if (CommandActions.DETAILS.equals(command)) {
newTagDetails(url, ignore, metalake, getOneTag(tags)).handle();
} else if (CommandActions.LIST.equals(command)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private void handleOnlyOneTag() {
return;
}

System.out.println(tags[0] + " created");
System.out.println("Tag " + tags[0] + " created");
}

private void handleMultipleTags() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,13 @@ private void handleMultipleTags() {
if (deleted.size() < tags.length) {
List<String> remaining = Arrays.asList(tags);
remaining.removeAll(deleted);
System.out.println("Tags " + String.join(",", deleted) + " not deleted.");
System.out.println("Tags " + String.join(",", remaining) + " not deleted.");
}
}

private void handleOnlyOneTag() {
boolean deleted = false;

if (!AreYouSure.really(force)) {
return;
}

try {
GravitinoClient client = buildClient(metalake);
deleted = client.deleteTag(tags[0]);
Expand All @@ -116,9 +112,9 @@ private void handleOnlyOneTag() {
}

if (deleted) {
System.out.println(tags[0] + " deleted.");
System.out.println("Tag " + tags[0] + " deleted.");
} else {
System.out.println(tags[0] + " not deleted.");
System.out.println("Tag " + tags[0] + " not deleted.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,6 @@ public void handle() {

String all = String.join(",", tagsToAdd);

System.out.println(entity + " tagged with " + all);
System.out.println(entity + " now tagged with " + all);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ public void handle() {
all = "nothing";
}

System.out.println(
entity + " removed tag " + String.join(",", tags) + " now tagged with " + all);
if (tags.length > 1) {
System.out.println(
entity + " removed tags " + String.join(",", tags) + " now tagged with " + all);
} else {
System.out.println(entity + " removed tag " + tags[0].toString() + " now tagged with " + all);
}
}
}

0 comments on commit f902f2f

Please sign in to comment.