tengqm commented on code in PR #5793:
URL: https://github.com/apache/gravitino/pull/5793#discussion_r1875865503
##########
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:
makes sense. When we have a list of things to maintain, I am more inclined
to have
it sorted, in an order that is easy to be understood with a quick glimpse.
The order can be a shared view of the things or a similar common
understanding.
The alpha-beta order is only a fall back when people don't share the same
opinion
about why X comes after Y.
An sorted list is easy to review and easy to maintain. Say when you want to
add a
new case, people won't ask you why you place your new code here rather than
there.
Say when you want to find the logic for a specific case, you can quickly
locate
the code.
Anyway, so long we have a common understanding on a fixed order, this is
fine.
I'm not strongly opinionated wrt the way it is sorted.
--
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]