Class CommandLine.Builder

java.lang.Object
org.apache.commons.cli.CommandLine.Builder
Enclosing class:
CommandLine

public static final class CommandLine.Builder extends Object
A nested builder class to create CommandLine instance using descriptive methods.
Since:
1.4
  • Field Details

    • DEPRECATED_HANDLER

      static final Consumer<Option> DEPRECATED_HANDLER
      Prints an Option to System.out.
    • args

      private final List<String> args
      The unrecognized options/arguments
    • options

      private final List<Option> options
      The processed options
    • deprecatedHandler

      private Consumer<Option> deprecatedHandler
      Deprecated Option handler.
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • addArg

      public CommandLine.Builder addArg(String arg)
      Adds left-over unrecognized option/argument.
      Parameters:
      arg - the unrecognized option/argument.
      Returns:
      this Builder instance for method chaining.
    • addOption

      public CommandLine.Builder addOption(Option opt)
      Adds an option to the command line. The values of the option are stored.
      Parameters:
      opt - the processed option.
      Returns:
      this Builder instance for method chaining.
    • build

      public CommandLine build()
      Creates the new instance.
      Returns:
      the new instance.
    • setDeprecatedHandler

      public CommandLine.Builder setDeprecatedHandler(Consumer<Option> deprecatedHandler)
      Sets the deprecated option handler.
      Parameters:
      deprecatedHandler - the deprecated option handler.
      Returns:
      this.
      Since:
      1.7.0