Class Args.Builder

java.lang.Object
org.apache.juneau.commons.runtime.Args.Builder
Enclosing class:
Args

public static class Args.Builder extends Object
Builder for Args with configurable grammar hooks.

Defaults match the legacy -key value [value...] parsing plus the natural extensions (--key, --key=value, -Dkey=value). Toggle individual options off to restrict the grammar.

  • Constructor Details

  • Method Details

    • allowEquals

      public Args.Builder allowEquals(boolean value)
      Enables or disables recognition of the --key=value / -key=value form.
      Parameters:
      value - true to recognize the equals form. Default true.
      Returns:
      This object.
    • allowShortFlags

      public Args.Builder allowShortFlags(boolean value)
      Enables or disables recognition of short-flag prefix -.
      Parameters:
      value - true to recognize -key-style flags. Default true.
      Returns:
      This object.
    • allowLongFlags

      public Args.Builder allowLongFlags(boolean value)
      Enables or disables recognition of long-flag prefix --.
      Parameters:
      value - true to recognize --key-style flags. Default true.
      Returns:
      This object.
    • allowSystemPropStyle

      public Args.Builder allowSystemPropStyle(boolean value)
      Enables or disables Java system-property style -Dkey=value parsing (strips the leading D).
      Parameters:
      value - true to recognize -Dkey=value. Default true.
      Returns:
      This object.
    • caseSensitive

      public Args.Builder caseSensitive(boolean value)
      Controls whether named-option lookups are case-sensitive.
      Parameters:
      value - true for case-sensitive lookups. Default true.
      Returns:
      This object.
    • customPrefix

      public Args.Builder customPrefix(String... prefixes)
      Overrides the default flag prefixes ("-" and "--").

      Pass an empty array to disable flag parsing entirely (every token becomes positional). When set, this supersedes allowShortFlags(boolean) and allowLongFlags(boolean).

      Parameters:
      prefixes - The replacement prefix list, or null to keep the default behavior.
      Returns:
      This object.
    • build

      public Args build(String line)
      Parses the given command-line string into an Args instance.
      Parameters:
      line - The raw command line. Can be null (treated as an empty argv).
      Returns:
      A new immutable Args instance.
    • build

      public Args build(String[] argv)
      Parses the given argv array into an Args instance.
      Parameters:
      argv - The arguments. Can be null (treated as an empty argv).
      Returns:
      A new immutable Args instance.