netudima commented on code in PR #2497: URL: https://github.com/apache/cassandra/pull/2497#discussion_r2098924937
########## src/java/org/apache/cassandra/tools/nodetool/Help.java: ########## @@ -0,0 +1,162 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.cassandra.tools.nodetool; + +import java.io.PrintWriter; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import com.google.common.base.Preconditions; +import com.google.common.base.Strings; + +import org.apache.cassandra.tools.nodetool.layout.CassandraCliHelpLayout; +import picocli.CommandLine; +import picocli.CommandLine.Command; +import picocli.CommandLine.IHelpCommandInitializable2; +import picocli.CommandLine.Option; +import picocli.CommandLine.Parameters; + +import static picocli.CommandLine.Model.UsageMessageSpec.SECTION_KEY_COMMAND_LIST; +import static picocli.CommandLine.Model.UsageMessageSpec.SECTION_KEY_COMMAND_LIST_HEADING; +import static picocli.CommandLine.Model.UsageMessageSpec.SECTION_KEY_EXIT_CODE_LIST; +import static picocli.CommandLine.Model.UsageMessageSpec.SECTION_KEY_EXIT_CODE_LIST_HEADING; +import static picocli.CommandLine.Model.UsageMessageSpec.SECTION_KEY_FOOTER; +import static picocli.CommandLine.Model.UsageMessageSpec.SECTION_KEY_FOOTER_HEADING; +import static picocli.CommandLine.Model.UsageMessageSpec.SECTION_KEY_HEADER; +import static picocli.CommandLine.Model.UsageMessageSpec.SECTION_KEY_HEADER_HEADING; +import static picocli.CommandLine.Model.UsageMessageSpec.SECTION_KEY_SYNOPSIS; + +@Command(name = "help", + helpCommand = true, + description = "Display help information") +public class Help implements IHelpCommandInitializable2, Runnable +{ + @Option(names = { "--help" }, hidden = true, usageHelp = true, descriptionKey = "helpCommand.help", + description = "Show usage help for the help command and exit.") + private boolean helpRequested; + + @Parameters(paramLabel = "command", arity = "1..*", descriptionKey = "helpCommand.command", + description = "The COMMAND to display the usage help message for.") + private List<String> commands; + + private CommandLine self; + private PrintWriter out; + private CommandLine.Help.ColorScheme colorScheme; + + /** + * Invokes {@code #usage(PrintStream, CommandLine.Help.ColorScheme) usage} for the specified command, + * or for the parent command. + */ + @Override + public void run() + { + CommandLine parent = self == null ? null : self.getParent(); + if (parent == null) + return; + + CommandLine.Help.ColorScheme colors = colorScheme == null ? + CommandLine.Help.defaultColorScheme(CommandLine.Help.Ansi.AUTO) : + colorScheme; + + if (commands == null) + { + // If the parent command is the top-level command, print help for the top-level command. + printTopCommandUsage(parent, colors, out); + return; + } + + if (parent.isAbbreviatedSubcommandsAllowed()) + throw new CommandLine.ParameterException(parent, "Abbreviated subcommands are not allowed."); + + // Pritn help for the last command in the list of commands. Review Comment: typo in the 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: 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