sunxiaojian commented on code in PR #5641:
URL: https://github.com/apache/gravitino/pull/5641#discussion_r1855401472
##########
clients/cli/src/main/java/org/apache/gravitino/cli/commands/DeleteTag.java:
##########
@@ -28,52 +31,55 @@
public class DeleteTag extends Command {
protected final String metalake;
- protected final String tag;
+ protected final String[] tags;
protected final boolean force;
/**
- * Delete a tag.
+ * Delete tags.
*
* @param url The URL of the Gravitino server.
* @param ignoreVersions If true don't check the client/server versions
match.
* @param force Force operation.
* @param metalake The name of the metalake.
- * @param tag The name of the tag.
+ * @param tags The names of the tags.
*/
- public DeleteTag(String url, boolean ignoreVersions, boolean force, String
metalake, String tag) {
+ public DeleteTag(
+ String url, boolean ignoreVersions, boolean force, String metalake,
String[] tags) {
super(url, ignoreVersions);
this.force = force;
this.metalake = metalake;
- this.tag = tag;
+ this.tags = tags;
}
- /** Delete a tag. */
+ /** Delete tags. */
@Override
public void handle() {
- boolean deleted = false;
-
if (!AreYouSure.really(force)) {
return;
}
-
+ List<String> deleted = new ArrayList<>();
try {
GravitinoClient client = buildClient(metalake);
- deleted = client.deleteTag(tag);
+ for (String tag : tags) {
+ if (client.deleteTag(tag)) {
+ deleted.add(tag);
+ }
+ }
} catch (NoSuchMetalakeException err) {
System.err.println(ErrorMessages.UNKNOWN_METALAKE);
- return;
} catch (NoSuchTagException err) {
System.err.println(ErrorMessages.UNKNOWN_TAG);
- return;
} catch (Exception exp) {
System.err.println(exp.getMessage());
- return;
- }
-
- if (deleted) {
- System.out.println(tag + " deleted.");
- } else {
- System.out.println(tag + " not deleted.");
+ } finally {
+ if (!deleted.isEmpty()) {
+ System.out.println(String.join(",", deleted) + " deleted.");
+ if (deleted.size() < tags.length) {
+ List<String> remaining = Arrays.asList(tags);
+ remaining.removeAll(deleted);
+ System.out.println(String.join(",", remaining) + " not deleted.");
Review Comment:
fixed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]