Mmuzaf commented on code in PR #2497: URL: https://github.com/apache/cassandra/pull/2497#discussion_r2204498928
########## src/java/org/apache/cassandra/tools/NodeTool.java: ########## @@ -339,6 +144,62 @@ private static void printHistory(String... args) } } + + public static List<String> getCommandsWithoutRoot(String separator) + { + List<String> commands = new ArrayList<>(); + try + { + getCommandsWithoutRoot(createCommandLine(new CassandraCliFactory(new NodeProbeFactory(), Output.CONSOLE)), commands, separator); + return commands; + } + catch (Exception e) + { + throw new RuntimeException("Failed to initialize command line hierarchy", e); + } + } + + 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); + } + + public static CommandLine createCommandLine(CommandLine.IFactory factory) throws Exception + { + return new CommandLine(new TopLevelCommand(), factory) + .addMixin(JmxConnect.MIXIN_KEY, factory.create(JmxConnect.class)); + } + + private static void configureCliLayout(CommandLine commandLine) + { + CliLayout defaultLayout = CliLayout.valueOf(toUpperCaseLocalized(CassandraRelevantProperties.CASSANDRA_CLI_LAYOUT.getDefaultValue())); + CliLayout layoutEnv = CassandraRelevantEnv.CASSANDRA_CLI_LAYOUT.getEnum(true, CliLayout.class, + CassandraRelevantProperties.CASSANDRA_CLI_LAYOUT.getDefaultValue()); + CliLayout layoutSysEnv = CassandraRelevantProperties.CASSANDRA_CLI_LAYOUT.getEnum(true, CliLayout.class); 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