shaofengshi commented on code in PR #5793:
URL: https://github.com/apache/gravitino/pull/5793#discussion_r1882285805
##########
clients/cli/src/main/java/org/apache/gravitino/cli/GravitinoCommandLine.java:
##########
@@ -162,39 +162,59 @@ private void handleMetalakeCommand() {
Command.setAuthenticationMode(auth, userName);
- if (CommandActions.DETAILS.equals(command)) {
- if (line.hasOption(GravitinoOptions.AUDIT)) {
- newMetalakeAudit(url, ignore, metalake).handle();
- } else {
- newMetalakeDetails(url, ignore, outputFormat, metalake).handle();
- }
- } else if (CommandActions.LIST.equals(command)) {
- newListMetalakes(url, ignore, outputFormat).handle();
- } else if (CommandActions.CREATE.equals(command)) {
- String comment = line.getOptionValue(GravitinoOptions.COMMENT);
- newCreateMetalake(url, ignore, metalake, comment).handle();
- } else if (CommandActions.DELETE.equals(command)) {
- boolean force = line.hasOption(GravitinoOptions.FORCE);
- newDeleteMetalake(url, ignore, force, metalake).handle();
- } else if (CommandActions.SET.equals(command)) {
- String property = line.getOptionValue(GravitinoOptions.PROPERTY);
- String value = line.getOptionValue(GravitinoOptions.VALUE);
- newSetMetalakeProperty(url, ignore, metalake, property, value).handle();
- } else if (CommandActions.REMOVE.equals(command)) {
- String property = line.getOptionValue(GravitinoOptions.PROPERTY);
- newRemoveMetalakeProperty(url, ignore, metalake, property).handle();
- } else if (CommandActions.PROPERTIES.equals(command)) {
- newListMetalakeProperties(url, ignore, metalake).handle();
- } else if (CommandActions.UPDATE.equals(command)) {
- if (line.hasOption(GravitinoOptions.COMMENT)) {
+ switch (command) {
+ case CommandActions.DETAILS:
+ if (line.hasOption(GravitinoOptions.AUDIT)) {
+ newMetalakeAudit(url, ignore, metalake).handle();
+ } else {
+ newMetalakeDetails(url, ignore, outputFormat, metalake).handle();
+ }
+ break;
+
+ case CommandActions.LIST:
+ newListMetalakes(url, ignore, outputFormat).handle();
+ break;
+
+ case CommandActions.CREATE:
String comment = line.getOptionValue(GravitinoOptions.COMMENT);
- newUpdateMetalakeComment(url, ignore, metalake, comment).handle();
- }
- if (line.hasOption(GravitinoOptions.RENAME)) {
- String newName = line.getOptionValue(GravitinoOptions.RENAME);
+ newCreateMetalake(url, ignore, metalake, comment).handle();
+ break;
+
+ case CommandActions.DELETE:
boolean force = line.hasOption(GravitinoOptions.FORCE);
- newUpdateMetalakeName(url, ignore, force, metalake, newName).handle();
- }
+ newDeleteMetalake(url, ignore, force, metalake).handle();
+ break;
+
+ case CommandActions.SET:
+ String property = line.getOptionValue(GravitinoOptions.PROPERTY);
+ String value = line.getOptionValue(GravitinoOptions.VALUE);
+ newSetMetalakeProperty(url, ignore, metalake, property,
value).handle();
+ break;
+
+ case CommandActions.REMOVE:
+ property = line.getOptionValue(GravitinoOptions.PROPERTY);
+ newRemoveMetalakeProperty(url, ignore, metalake, property).handle();
+ break;
+
+ case CommandActions.PROPERTIES:
+ newListMetalakeProperties(url, ignore, metalake).handle();
+ break;
+
+ case CommandActions.UPDATE:
+ if (line.hasOption(GravitinoOptions.COMMENT)) {
+ comment = line.getOptionValue(GravitinoOptions.COMMENT);
+ newUpdateMetalakeComment(url, ignore, metalake, comment).handle();
+ }
+ if (line.hasOption(GravitinoOptions.RENAME)) {
+ String newName = line.getOptionValue(GravitinoOptions.RENAME);
+ force = line.hasOption(GravitinoOptions.FORCE);
+ newUpdateMetalakeName(url, ignore, force, metalake,
newName).handle();
+ }
+ break;
+
+ default:
+ System.err.println(ErrorMessages.UNSUPPORTED_COMMAND);
+ break;
Review Comment:
All make sense, both are okay for me; Thanks a lot for Qiming's comment!
--
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]