Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: CliOptions

[127:7] extends: object

CliOptions is a reusable collection of CliOption declarations. It stores the logical option definitions and lazily creates a new Apache Commons CLI Options object whenever parsing or help formatting needs one. That lets callers keep configuring options after adding them without the Java-side option set getting stale.

Members

  • items

Methods

  • CliOptions ()

    Creates an empty set of command-line options.

  • add (Opt)

    Adds an existing option declaration to the set.

    • @p Opt is the CliOption to add.
    • @r this option set for chaining.
  • flag (string ShortName = null, string LongName = null, string Description = null)

    Creates and adds a flag option that does not take a value.

    • @p ShortName is the short option name without -.
    • @p LongName is the long option name without --.
    • @p Description is the help text for the flag.
    • @r The created CliOption so callers can keep configuring it if needed.
  • value (string ShortName = null, string LongName = null, string Description = null, bool Required = false)

    Creates and adds an option that expects a single value.

    • @p ShortName is the short option name without -.
    • @p LongName is the long option name without --.
    • @p Description is the help text for the option.
    • @p Required is true when the option must be supplied.
    • @r The created CliOption so callers can keep configuring it if needed.
  • optionList ()

    Returns the logical option declarations in insertion order.

    • @r A list of CliOption objects.
  • rawOptions ()

    Builds and returns the wrapped Apache Commons CLI Options object. This is the AJI escape hatch for advanced callers.

    • @r An AussomJavaObject wrapping org.apache.commons.cli.Options.

class: CliOption

[16:7] extends: object

CliOption describes one command-line option declaration for CliParser. It captures the short name, long name, description, whether the option expects a value, whether it is required, and the display name used for the value in help output. The wrapper stays mutable while the option is being configured, then lazily creates the underlying Apache Commons CLI Option object when the parser needs it.

Members

  • shortNameValue
  • longNameValue
  • descriptionValue
  • hasArgValue
  • requiredValue
  • argNameValue
  • builtOption

Methods

  • CliOption (string ShortName = null, string LongName = null, string Description = null)

    Creates a new command-line option declaration.

    • @p ShortName is the one-character or short option name without -.
    • @p LongName is the long option name without --.
    • @p Description is the help text shown for the option.
  • arg (bool HasArg = true)

    Marks whether the option expects a value argument.

    • @p HasArg is true when the option should consume a value.
    • @r this option for chaining.
  • required (bool Required = true)

    Marks whether the option is required.

    • @p Required is true when parsing should fail if the option is omitted.
    • @r this option for chaining.
  • argName (string Name)

    Sets the display name used for the option value in generated help text.

    • @p Name is the placeholder shown after the option name.
    • @r this option for chaining.
  • canonicalName ()

    Returns the preferred public key for this option. Long names are preferred when present, otherwise the short name is used.

    • @r A string with the canonical option key.
  • build ()

    Builds and returns the wrapped Apache Commons CLI Option object. Advanced users can use this as an AJI escape hatch when they need the raw Java object.

    • @r An AussomJavaObject wrapping org.apache.commons.cli.Option.

class: CliParser

[359:7] extends: object

CliParser parses a list of command-line arguments using a declared CliOptions set and returns a CliParseResult. It wraps Apache Commons CLI through AJI, formats help text on demand, and keeps the public API small and script-friendly while still exposing the raw Apache Options object through CliOptions.rawOptions() for advanced use.

Members

  • optionSet

Methods

  • CliParser ()

    Creates a new parser with an empty option set.

  • options (Opts)

    Sets the option declarations used for future parses and help output.

    • @p Opts is the CliOptions set to use.
    • @r this parser for chaining.
  • parse (list Args)

    Parses the provided argument list. Apache Commons CLI parse failures are surfaced as exceptions.

    • @p Args is the command-line argument list to parse.
    • @r A CliParseResult with the parsed values.
  • parseOrExit (list Args, string Usage = null)

    Parses the provided argument list and prints a readable error plus help text when parsing fails.

    • @p Args is the command-line argument list to parse.
    • @p Usage is the command syntax line shown in help output.
    • @r A CliParseResult on success or null on failure.
  • formatHelp (string Usage = null)

    Formats the current option set as help text.

    • @p Usage is the command syntax line shown at the top of the help output.
    • @r A string with the formatted help text.
  • help (string Usage = null)

    Prints formatted help text for the current option set.

    • @p Usage is the command syntax line shown at the top of the help output.
    • @r this parser for chaining.

class: CliParseResult

[207:7] extends: object

CliParseResult exposes the parsed option and argument values returned by Apache Commons CLI using plain Aussom values where possible. Options can be queried by either short or long name, positional arguments are exposed as an Aussom list, and toMap() returns a compact summary of the declared options plus the remaining positional arguments.

Members

  • rawCommandLine
  • optionDefs

Methods

  • CliParseResult (object RawCommandLine, list OptionDefs)

    Creates a wrapped parse result.

    • @p RawCommandLine is the wrapped Apache Commons CLI CommandLine object.
    • @p OptionDefs is the list of declared CliOption definitions.
  • has (string Name)

    Returns true when the named option was present on the command line. Either the short or long option name may be used.

    • @p Name is the short or long option name to check.
    • @r A bool with true when the option is present.
  • value (string Name, Default = null)

    Returns the first parsed value for an option or the provided default. Either the short or long option name may be used.

    • @p Name is the short or long option name.
    • @p Default is the value to return when the option was not provided.
    • @r The parsed string value or Default.
  • values (string Name)

    Returns all parsed values for an option as an Aussom list. This is useful when the same option is repeated multiple times.

    • @p Name is the short or long option name.
    • @r A list of parsed values. The list is empty when the option was not supplied.
  • args ()

    Returns the remaining positional arguments after option parsing.

    • @r A list of positional argument strings.
  • arg (int Index, Default = null)

    Returns one positional argument by index or the provided default.

    • @p Index is the zero-based positional argument index.
    • @p Default is the value to return when the index is out of range.
    • @r The positional argument string or Default.
  • toMap ()

    Converts the parsed result into a plain Aussom map. Flag options become bool values. Value-taking options become a string when one value was supplied or a list when the option appeared multiple times. Positional arguments are stored under the args key.

    • @r A map with the parsed option state and positional arguments.
  • javaListToList (JavaList)

    Converts a wrapped Java List into an Aussom list.

    • @p JavaList is the wrapped Java list to copy from.
    • @r A new Aussom list with the copied values.
  • arrayToList (Arr)

    Converts a wrapped Java array into an Aussom list.

    • @p Arr is the wrapped Java array to copy from.
    • @r A new Aussom list with the copied values.