Class HelpPrinter

java.lang.Object
software.amazon.smithy.cli.HelpPrinter

public final class HelpPrinter extends Object
Generates and prints structured help output.
  • Constructor Details

    • HelpPrinter

      public HelpPrinter(String name)
  • Method Details

    • maxWidth

      public HelpPrinter maxWidth(int maxWidth)
    • fromArguments

      public static HelpPrinter fromArguments(String name, Arguments arguments)
      Create a HelpPrinter that registers help options and parameters defined in the given arguments.
      Parameters:
      name - Name of the command.
      arguments - Arguments to extract params from.
      Returns:
      Returns the created HelpPrinter.
    • summary

      public HelpPrinter summary(String summary)
      Defines the summary text of the command that comes after the short argument description and before the long argument descriptions.
      Parameters:
      summary - Summary text to display.
      Returns:
      Returns the printer.
    • documentation

      public HelpPrinter documentation(String documentation)
      Defines the optional long-form documentation that comes after long argument descriptions.
      Parameters:
      documentation - Documentation to display.
      Returns:
      Returns the printer.
    • option

      public HelpPrinter option(String longName, String shortName, String description)
      Adds an option that takes no argument value.
      Parameters:
      longName - Nullable argument long form (e.g., "--foo").
      shortName - Nullable argument short form (e.g., null).
      description - Description description of the argument.
      Returns:
      Returns the printer.
    • param

      public HelpPrinter param(String longName, String shortName, String exampleValue, String description)
      Adds a parameter that requires an argument value.
      Parameters:
      longName - Nullable argument long form (e.g., "--foo").
      shortName - Nullable argument short form (e.g., null).
      exampleValue - Example value of the parameter (e.g., "FOO").
      description - Description description of the argument.
      Returns:
      Returns the printer.
    • positional

      public HelpPrinter positional(String name, String description)
      Defines a positional argument.
      Parameters:
      name - Name of the positional argument (e.g., <MODEL...>)
      description - Description of the argument.
      Returns:
      Returns the printer.
    • print

      public void print(ColorFormatter colors, CliPrinter printer)
      Prints the generated help to the given printer.
      Parameters:
      colors - Color formatter.
      printer - CliPrinter to write to.