PakhomovAlexander commented on code in PR #2360:
URL: https://github.com/apache/ignite-3/pull/2360#discussion_r1276211333


##########
modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/cluster/unit/UnitDeployOptionsMixin.java:
##########
@@ -73,26 +70,37 @@ private void setPath(Path value) {
     )
     private void setNodes(List<String> values) {
         if (values.size() > 1) {
-            Optional<DeployMode> deployMode = values.stream()
-                    .map(value -> {
-                        try {
-                            return DeployMode.fromValue(value);
-                        } catch (IllegalArgumentException ignored) {
-                            return null;
-                        }
-                    })
-                    .filter(Objects::nonNull)
-                    .findAny();
-            if (deployMode.isPresent()) {
-                throw new ParameterException(spec.commandLine(), "There could 
be only one deploy mode option");
+            List<NodesAlias> aliases = new ArrayList<>();
+            List<String> nodeNames = new ArrayList<>();
+            values.forEach(it -> {
+                String trimmed = it.trim();
+                NodesAlias alias = NodesAlias.parse(trimmed);
+                if (alias != null) {
+                    aliases.add(alias);
+                } else {
+                    nodeNames.add(trimmed);
+                }
+            });
+            if (aliases.size() > 1) {
+                throw new ParameterException(
+                        spec.commandLine(),
+                        "Aliases " + aliases + " can not be specified 
together. Provide single alias, please."
+                );
+            } else if (aliases.size() == 1) {
+                throw new ParameterException(
+                        spec.commandLine(),
+                        "Alias " + aliases.get(0) + " couldn't be used with 
explicit nodes names list "
+                                + nodeNames
+                                + ". Provide either node names list of single 
alias."

Review Comment:
   ```suggestion
                                   + ". Provide either node names list or 
single alias."
   ```



##########
modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/Options.java:
##########
@@ -81,6 +85,10 @@ public String shortName() {
         return shortName;
     }
 
+    public Set<String> names() {
+        return Stream.of(fullName, shortName).collect(toSet());

Review Comment:
   ```suggestion
           return Set.of(fullName, shortName);
   ```



##########
modules/cli/src/test/java/org/apache/ignite/internal/cli/commands/unit/DeployCommandTest.java:
##########
@@ -52,7 +52,8 @@ void aliasesWithExplicitNodesList(@WorkDirectory Path 
workDir) throws IOExceptio
         assertAll(
                 () -> assertExitCodeIs(2),
                 this::assertOutputIsEmpty,
-                () -> assertErrOutputContains("Aliases couldn't be used with 
explicit nodes list")
+                () -> assertErrOutputContains("Alias ALL couldn't be used with 
explicit nodes names list [foo]. "
+                        + "Provide either node names list of single alias.")

Review Comment:
   ```suggestion
                           + "Provide either node names list or single alias.")
   ```



-- 
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]

Reply via email to