ur_rna.Utilities

## Class CommandLineParser

- java.lang.Object
- - ur_rna.Utilities.CommandLineParser

-     public class CommandLineParser
      extends java.lang.Object

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `CommandLineParser.Argument` Arguments are the results of parsing a commandline.
    `static class` | `CommandLineParser.FlagArg` Flags arguments are indicated by a preceding hyphen (-) or slash (/).
    `static class` | `CommandLineParser.FlagDef` Contains information about flags expected on the command-line.
    `static class` | `CommandLineParser.ParamAffinity` Describes whether a parameter value is required, optional (allowed), or forbidden (invalid) for a given flag.
    `static class` | `CommandLineParser.ParseResults`
    `static class` | `CommandLineParser.UnnamedArg` Unnamed Arguments are those that stand alone on the command line.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `boolean` | `allowUndefinedFlags` Whether or not to allow undefined flags when parsing the command line.
    `boolean` | `defaultAllowRepeatFlags`
    `CommandLineParser.ParamAffinity` | `defaultParamAffinity`
    `private java.util.HashMap<java.lang.String,CommandLineParser.FlagDef>` | `flagDefMap`
    `boolean` | `ignoreFlagCase`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CommandLineParser()`
    `CommandLineParser(boolean ignoreFlagCase)`
    `CommandLineParser(boolean ignoreFlagCase, CommandLineParser.ParamAffinity defaultParamAffinity, boolean defaultAllowRepeatFlags)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addFlag(CommandLineParser.FlagDef f)`
    `CommandLineParser.FlagDef` | `addFlag(java.lang.String... aliases)`
    `CommandLineParser.FlagDef` | `addFlag(java.lang.String flagName, boolean requiresParameter)` Add a flag and specify whether or not it requires a following parameter.
    `CommandLineParser.FlagDef` | `addFlag(java.lang.String name, CommandLineParser.ParamAffinity canHaveParams, boolean allowRepeats, java.lang.String... aliases)`
    `void` | `addFlagAlias(CommandLineParser.FlagDef f, java.lang.String alias)`
    `void` | `addFlagAlias(java.lang.String existingName, java.lang.String alias)`
    `java.lang.String` | `addFlagPrefix(java.lang.String s)`
    `void` | `addFlags(java.lang.String... flagNames)` Define flags that do NOT have parameters.
    `void` | `addFlagsWithParams(java.lang.String... flagNames)` Define flags that have (and require) parameters.
    `CommandLineParser.FlagDef` | `findFlagDef(java.lang.String nameOrAlias)` Finds the FlagDef associated with the given name.
    `CommandLineParser.FlagDef` | `findFlagDef(java.lang.String nameOrAlias, boolean required)` /** Finds the FlagDef associated with the given name.
    `java.util.Set<CommandLineParser.FlagDef>` | `getFlagDefinitions()`
    `java.lang.String` | `getUsageMessage()`
    `java.lang.String` | `normalizeFlagName(java.lang.String flagName)`
    `CommandLineParser.ParseResults` | `parse(java.lang.String commandLine)`
    `CommandLineParser.ParseResults` | `parse(java.lang.String[] commandArgs)`
    `java.util.List<CommandLineParser.FlagDef>` | `parseFlagDefs(java.lang.String flagDefSpecifier)`
    `java.util.List<CommandLineParser.FlagDef>` | `parseFlagDefs(java.lang.String flagDefSpecifier, boolean addResults)`
    `java.lang.String` | `removeFlagPrefix(java.lang.String s)`
    `private Pair<java.lang.String,java.lang.String>` | `splitFlagValue(java.lang.String flagNameAndValue)`

    - ### Methods inherited from class java.lang.Object

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

- - ### Field Detail

    - #### allowUndefinedFlags

          public boolean allowUndefinedFlags

      Whether or not to allow undefined flags when parsing the command line. If this is true and an undefined flag is encountered, a new FlagDef will automatically be created. The new FlagDef will have the found flag as its `name` value and it will have no `aliases`. The values for `allowRepeats` and `paramAffinity` will be `defaultAllowRepeatFlags` and `defaultParamAffinity` respectively.

    - #### defaultAllowRepeatFlags

          public boolean defaultAllowRepeatFlags

    - #### defaultParamAffinity

          public CommandLineParser.ParamAffinity defaultParamAffinity

    - #### flagDefMap

          private final java.util.HashMap<java.lang.String,CommandLineParser.FlagDef> flagDefMap

    - #### ignoreFlagCase

          public final boolean ignoreFlagCase

  - ### Constructor Detail

    - #### CommandLineParser

          public CommandLineParser()

    - #### CommandLineParser

          public CommandLineParser(boolean ignoreFlagCase)

    - #### CommandLineParser

          public CommandLineParser(boolean ignoreFlagCase,
                                   CommandLineParser.ParamAffinity defaultParamAffinity,
                                   boolean defaultAllowRepeatFlags)

  - ### Method Detail

    - #### addFlag

          public void addFlag(CommandLineParser.FlagDef f)

    - #### addFlag

          public CommandLineParser.FlagDef addFlag(java.lang.String... aliases)

    - #### addFlag

          public CommandLineParser.FlagDef addFlag(java.lang.String flagName,
                                                   boolean requiresParameter)

      Add a flag and specify whether or not it requires a following parameter.
      Parameters:
        `flagName` - The name of the flag. If `ignoreFlagCase`, it will be converted to lower case.
        `requiresParameter` - Whether or not the flag requires a parameter. (The parameter is never optional.)

    - #### addFlag

          public CommandLineParser.FlagDef addFlag(java.lang.String name,
                                                   CommandLineParser.ParamAffinity canHaveParams,
                                                   boolean allowRepeats,
                                                   java.lang.String... aliases)

    - #### addFlagAlias

          public void addFlagAlias(CommandLineParser.FlagDef f,
                                   java.lang.String alias)

    - #### addFlagAlias

          public void addFlagAlias(java.lang.String existingName,
                                   java.lang.String alias)

    - #### addFlagPrefix

          public java.lang.String addFlagPrefix(java.lang.String s)

    - #### addFlags

          public void addFlags(java.lang.String... flagNames)

      Define flags that do NOT have parameters.
      Parameters:
        `flagNames` - An array or list of flag names.

    - #### addFlagsWithParams

          public void addFlagsWithParams(java.lang.String... flagNames)

      Define flags that have (and require) parameters.
      Parameters:
        `flagNames` - An array or list of flag names.

    - #### findFlagDef

          public CommandLineParser.FlagDef findFlagDef(java.lang.String nameOrAlias)

      Finds the FlagDef associated with the given name.
      Parameters:
        `nameOrAlias` - The name or alias to search for. This can be either the `name` of the FlagDef or one of its `aliases`.
      Returns:
        The FlagDef associated with the given name or alias, or null if no matching FlagDef has been defined.

    - #### findFlagDef

          public CommandLineParser.FlagDef findFlagDef(java.lang.String nameOrAlias,
                                                       boolean required)

      /** Finds the FlagDef associated with the given name.
      Parameters:
        `nameOrAlias` - The name or alias to search for. This can be either the `name` of the FlagDef or one of its `aliases`.
        `required` - If true and the FlagDef is not defined, an exception will be thrown, unless `allowUndefinedFlags` is true, in which chase the exception will not be thrown.
      Returns:
        The FlagDef associated with the given name or alias, or null if no matching FlagDef has been defined.
      Throws:
        `java.lang.IllegalArgumentException` - if the FlagDef is not defined and `required` is true and `allowUndefinedFlags` is false.

    - #### getFlagDefinitions

          public java.util.Set<CommandLineParser.FlagDef> getFlagDefinitions()

    - #### getUsageMessage

          public java.lang.String getUsageMessage()

    - #### normalizeFlagName

          public java.lang.String normalizeFlagName(java.lang.String flagName)

    - #### parse

          public CommandLineParser.ParseResults parse(java.lang.String commandLine)
                                               throws SyntaxErrorException

      Throws:
        `SyntaxErrorException`

    - #### parse

          public CommandLineParser.ParseResults parse(java.lang.String[] commandArgs)
                                               throws SyntaxErrorException

      Throws:
        `SyntaxErrorException`

    - #### parseFlagDefs

          public java.util.List<CommandLineParser.FlagDef> parseFlagDefs(java.lang.String flagDefSpecifier)
                                                                  throws SyntaxErrorException

      Throws:
        `SyntaxErrorException`

    - #### parseFlagDefs

          public java.util.List<CommandLineParser.FlagDef> parseFlagDefs(java.lang.String flagDefSpecifier,
                                                                         boolean addResults)
                                                                  throws SyntaxErrorException

      Throws:
        `SyntaxErrorException`

    - #### removeFlagPrefix

          public java.lang.String removeFlagPrefix(java.lang.String s)

    - #### splitFlagValue

          private Pair<java.lang.String,java.lang.String> splitFlagValue(java.lang.String flagNameAndValue)