Mmuzaf commented on code in PR #3902:
URL: https://github.com/apache/cassandra/pull/3902#discussion_r1969814262


##########
src/java/org/apache/cassandra/tools/NodeTool.java:
##########
@@ -17,56 +17,35 @@
  */
 package org.apache.cassandra.tools;
 
-import static com.google.common.base.Throwables.getStackTraceAsString;
-import static com.google.common.collect.Iterables.toArray;
-import static com.google.common.collect.Lists.newArrayList;
-import static java.lang.Integer.parseInt;
-import static java.lang.String.format;
-import static org.apache.cassandra.io.util.File.WriteMode.APPEND;
-import static org.apache.commons.lang3.ArrayUtils.EMPTY_STRING_ARRAY;
-import static org.apache.commons.lang3.StringUtils.EMPTY;
-import static org.apache.commons.lang3.StringUtils.isEmpty;
-import static org.apache.commons.lang3.StringUtils.isNotEmpty;
-
-import java.io.Console;
-import org.apache.cassandra.io.util.File;
-import org.apache.cassandra.io.util.FileWriter;
-import java.io.FileNotFoundException;
 import java.io.IOError;
 import java.io.IOException;
-import java.net.UnknownHostException;
+import java.io.PrintWriter;
+import java.lang.reflect.Field;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.Date;
 import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Scanner;
-import java.util.SortedMap;
-
+import javax.inject.Inject;
 import javax.management.InstanceNotFoundException;
 
 import com.google.common.base.Joiner;
 import com.google.common.base.Throwables;
 
-import org.apache.cassandra.locator.EndpointSnitchInfoMBean;
-import org.apache.cassandra.tools.nodetool.*;
+import org.apache.cassandra.config.CassandraRelevantEnv;
+import org.apache.cassandra.config.CassandraRelevantProperties;

Review Comment:
   Fixed.



##########
src/java/org/apache/cassandra/tools/NodeTool.java:
##########
@@ -316,6 +142,58 @@ private static void printHistory(String... args)
         }
     }
 
+
+    public static List<String> getCommandsWithoutRoot(String separator)
+    {
+        List<String> commands = new ArrayList<>();
+        getCommandsWithoutRoot(createCommandLine(new CassandraCliFactory(new 
NodeProbeFactory(), Output.CONSOLE)), commands, separator);
+        return commands;
+    }
+
+    private static void getCommandsWithoutRoot(CommandLine cli, List<String> 
commands, String separator)
+    {
+        String name = cli.getCommandSpec().qualifiedName(separator);
+        // Skip the root command as it's not a real command.
+        if (cli.getCommandSpec().root() != cli.getCommandSpec())
+            
commands.add(name.replace(cli.getCommandSpec().root().qualifiedName() + 
separator, ""));
+        for (CommandLine sub : cli.getSubcommands().values())
+            getCommandsWithoutRoot(sub, commands, separator);
+    }
+
+    private static CommandLine createCommandLine(CassandraCliFactory factory)
+    {
+        return new CommandLine(new TopLevelCommand(), factory)
+                   .addMixin(JmxConnect.MIXIN_KEY, 
factory.create(JmxConnect.class))
+                   .setOut(new PrintWriter(factory.output.out, true))
+                   .setErr(new PrintWriter(factory.output.err, true));
+    }
+
+    private static void configureCliLayout(CommandLine commandLine)
+    {
+        CliLayout defaultLayout = 
CliLayout.valueOf(toUpperCaseLocalized(CASSANDRA_CLI_LAYOUT.getDefaultValue()));
+        CliLayout layoutEnv = 
CassandraRelevantEnv.CASSANDRA_CLI_LAYOUT.getEnum(true, CliLayout.class,
+                                                                               
 CASSANDRA_CLI_LAYOUT.getDefaultValue());
+        CliLayout layoutSysEnv = CASSANDRA_CLI_LAYOUT.getEnum(true, 
CliLayout.class);
+        CliLayout layout;
+        if (layoutEnv == layoutSysEnv)
+            layout = layoutEnv;
+        else
+            layout = layoutEnv == defaultLayout ? layoutSysEnv : layoutEnv;
+        switch (layout)
+        {
+            case AIRLINE:
+                commandLine.setHelpFactory(CassandraCliHelpLayout::new)
+                           
.setUsageHelpWidth(CassandraCliHelpLayout.DEFAULT_USAGE_HELP_WIDTH)
+                           
.setHelpSectionKeys(CassandraCliHelpLayout.cassandraHelpSectionKeys());
+                break;
+            case PICOCLI:
+                break;
+            default:
+                throw new IllegalStateException("Unknown CLI layout: " +
+                                                
CASSANDRA_CLI_LAYOUT.getString());

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: pr-unsubscr...@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org
For additional commands, e-mail: pr-h...@cassandra.apache.org

Reply via email to