# Class CommandLine.Builder

java.lang.Object
org.apache.commons.cli.CommandLine.Builder

All Implemented Interfaces:
  `Supplier<CommandLine>`

Enclosing class:
  `CommandLine`

public static final class CommandLine.Builder extends Object implements Supplier<CommandLine>
A nested builder class to create `CommandLine` instance using descriptive methods.

Since:
  1.4

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Builder()`
  Deprecated.
  Use `CommandLine.builder()`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `CommandLine.Builder`
  `addArg(String arg)`
  Adds left-over unrecognized option/argument.
  `CommandLine.Builder`
  `addOption(Option option)`
  Adds an option to the command line.
  `CommandLine`
  `build()`
  Deprecated.
  Use `get()`.
  `CommandLine`
  `get()`
  Creates a new instance.
  `CommandLine.Builder`
  `setDeprecatedHandler(Consumer<Option> deprecatedHandler)`
  Sets the deprecated option handler.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### Builder

    @Deprecated public Builder()
    Deprecated.
    Use `CommandLine.builder()`.
    Constructs a new instance.

- ## 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 option)
    Adds an option to the command line. The values of the option are stored.
    Parameters:
      `option` - the processed option.
    Returns:
      this Builder instance for method chaining.

  - ### build

    @Deprecated public CommandLine build()
    Deprecated.
    Use `get()`.
    Creates a new instance.
    Returns:
      a new instance.

  - ### get

    public CommandLine get()
    Creates a new instance.
    Specified by:
      `get` in interface `Supplier<CommandLine>`
    Returns:
      a new instance.
    Since:
      1.10.0

  - ### setDeprecatedHandler

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