mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

lutoff
30.50.2007 165cc33c42a1e3186b2d68decaa236bcfe83decf
Add 'hidden' feature to SubCommand.
2 files modified
41 ■■■■■ changed files
opends/src/server/org/opends/server/util/args/SubCommand.java 33 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/util/args/SubCommandArgumentParser.java 8 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/util/args/SubCommand.java
@@ -45,6 +45,10 @@
 */
public class SubCommand
{
  // Indicates whether this subCommand should be hidden in the usage
  // information.
  private boolean isHidden;
  // The mapping between the short argument IDs and the arguments for this
  // subcommand.
  private HashMap<Character,Argument> shortIDMap;
@@ -157,6 +161,7 @@
    this.minTrailingArguments = minTrailingArguments;
    this.maxTrailingArguments = maxTrailingArguments;
    this.trailingArgsDisplayName = trailingArgsDisplayName;
    this.isHidden  = false;
    String nameToCheck = name;
    if (parser.longArgumentsCaseSensitive())
@@ -450,5 +455,33 @@
  {
    return parser.getTrailingArguments();
  }
  /**
   * Indicates whether this subcommand should be hidden from the usage
   * information.
   *
   * @return <CODE>true</CODE> if this subcommand should be hidden
   *         from the usage information, or <CODE>false</CODE> if
   *         not.
   */
  public boolean isHidden()
  {
    return isHidden;
  }
  /**
   * Specifies whether this subcommand should be hidden from the usage
   * information.
   *
   * @param isHidden
   *          Indicates whether this subcommand should be hidden from
   *          the usage information.
   */
  public void setHidden(boolean isHidden)
  {
    this.isHidden = isHidden;
  }
}
opends/src/server/org/opends/server/util/args/SubCommandArgumentParser.java
@@ -1314,6 +1314,10 @@
    int indentNb = 0;
    for (SubCommand sc : subCommands.values())
    {
      if (sc.isHidden())
      {
        continue;
      }
      if (sc.getName().length() > indentNb )
      {
        indentNb = sc.getName().length();
@@ -1322,6 +1326,10 @@
    indentNb++;
    for (SubCommand sc : subCommands.values())
    {
      if (sc.isHidden())
      {
        continue;
      }
      buffer.append("    " + sc.getName());
      for (int i=0; i < indentNb - sc.getName().length() ; i++)
      {