Package com.unboundid.util.args
package com.unboundid.util.args
This package contains a set of classes that may be used to perform
command line argument parsing. Arguments can have a number of properties,
including:
If an argument takes a value, then it may be separated from the short or long identifier using a space, or an equal sign for long identifiers (e.g., "-h server.example.com", "--hostname server.example.com", or "--hostname=server.example.com"). In addition, if a short identifier is provided by itself without being concatenated with any other short identifiers, then the value may be directly appended to the short identifier (e.g., "-hserver.example.com"). Note that it is not possible for an argument to optionally take a value. If an argument is configured to take a value, then it can never be provided on the command line without one, and if an argument is not configured to take a value, then it can never be provided with one.
Arguments are generally separated from each other with one or more spaces. However, if there are multiple arguments that do not take values, then it is possible to concatenate their short identifiers together and prefix the resulting string with a single dash (e.g., "-abcd" would be interpreted as "-a -b -c -d"). This is only allowed for short identifiers, and only for the case in which none of them take values.
It is possible to define relationships between named arguments. It is possible to indicate that at most one of a specified set of arguments is allowed to be provided (i.e., that those arguments are not allowed to be used together). It is also possible to indicate that at least one of a specified set of arguments must be provided. If the same set of arguments is included in both classifications, then exactly one of those arguments must be provided.
In addition to named arguments, it is also possible to indicate that a command accepts unnamed trailing arguments. In this case, no automatic validation will be performed for those trailing arguments (with the optional exception of enforcing a limit on the maximum allowed number of such arguments), and it is up to the application to parse and interpret them. The first argument which is not the value for the previous argument and does not start with one or two dashes will be considered the first trailing argument, and all arguments after that (regardless of whether they start with dashes) will also be considered trailing arguments. Additionally, if an argument of "--" is provided by itself, then it will serve to mark as the end of the named arguments, and any arguments provided after that will be considered unnamed trailing arguments.
- A short identifier, which is a single character and is used by prefixing it with a single dash on the command line (e.g., "-H").
- A long identifier, which is a string and is used by prefixing it with two dashes on the command line (e.g., "--help"). Long arguments will be treated in a case-insensitive manner.
- A description, which provides basic information about the purpose of the argument. This makes it possible for the argument parser to generate usage information.
- A flag that indicates whether the argument takes a value. If it does, then it should also include a placeholder string to indicate what that value is supposed to be in the usage information.
- A flag that indicates whether the argument is required to be provided.
- A flag that indicates whether the argument is allowed to be provided multiple times. This can be useful for arguments that are allowed to be provided with multiple values, or for cases in which having an argument provided multiple times amplifies its meaning (e.g., "-v" enables basic debugging, whereas "-v -v -v" enables the most verbose debugging).
- A flag that indicates whether the argument is hidden. If an argument is hidden, it may be provided on the command line, but it will not be displayed in usage information.
If an argument takes a value, then it may be separated from the short or long identifier using a space, or an equal sign for long identifiers (e.g., "-h server.example.com", "--hostname server.example.com", or "--hostname=server.example.com"). In addition, if a short identifier is provided by itself without being concatenated with any other short identifiers, then the value may be directly appended to the short identifier (e.g., "-hserver.example.com"). Note that it is not possible for an argument to optionally take a value. If an argument is configured to take a value, then it can never be provided on the command line without one, and if an argument is not configured to take a value, then it can never be provided with one.
Arguments are generally separated from each other with one or more spaces. However, if there are multiple arguments that do not take values, then it is possible to concatenate their short identifiers together and prefix the resulting string with a single dash (e.g., "-abcd" would be interpreted as "-a -b -c -d"). This is only allowed for short identifiers, and only for the case in which none of them take values.
It is possible to define relationships between named arguments. It is possible to indicate that at most one of a specified set of arguments is allowed to be provided (i.e., that those arguments are not allowed to be used together). It is also possible to indicate that at least one of a specified set of arguments must be provided. If the same set of arguments is included in both classifications, then exactly one of those arguments must be provided.
In addition to named arguments, it is also possible to indicate that a command accepts unnamed trailing arguments. In this case, no automatic validation will be performed for those trailing arguments (with the optional exception of enforcing a limit on the maximum allowed number of such arguments), and it is up to the application to parse and interpret them. The first argument which is not the value for the previous argument and does not start with one or two dashes will be considered the first trailing argument, and all arguments after that (regardless of whether they start with dashes) will also be considered trailing arguments. Additionally, if an argument of "--" is provided by itself, then it will serve to mark as the end of the named arguments, and any arguments provided after that will be considered unnamed trailing arguments.
-
ClassDescriptionThis class defines a generic command line argument, which provides functionality applicable to all argument types.This class defines an exception that may be thrown if a problem occurs while parsing command line arguments or preparing the argument parser.This class defines an argument whose values are intended to be argument strings as might be provided to a command-line application (e.g., "--arg1 arg1value --arg2 --arg3 arg3value").This class provides an argument parser, which may be used to process command line arguments provided to Java applications.This class defines an API that may be used to create argument value validators, which can be used to enforce additional constraints on the values provided to an argument.This class provides an implementation of an argument value validator that is expected to be used with a string argument and ensures that all values for the argument are valid attribute type names (or numeric OIDs) or attribute descriptions (a name or OID with attribute options).Creates a new argument that is intended to represent Boolean states based on whether it was present in the provided set of command-line arguments.Creates a new argument that is intended to represent Boolean states based on the value provided for this argument.This class defines an argument that is intended to hold information about one or more LDAP controls.This class defines an argument that is intended to hold one or more distinguished name values.This class provides an implementation of an argument value validator that ensures that values can be parsed as valid DNS host names.Creates a new argument that is intended to represent a duration.This class defines an argument that is intended to hold values which refer to files on the local filesystem.This class defines an argument that is intended to hold one or more search filter values.This class provides an implementation of an argument value validator that ensures that values can be parsed as valid IA5 strings (that is, strings containing only ASCII characters).This class defines an argument that is intended to hold one or more integer values.This class provides an implementation of an argument value validator that ensures that values can be parsed as valid IPv4 or IPV6 addresses.This class provides an implementation of an argument value validator that is expected to be used with a string argument and ensures that all values for the argument are valid LDAP URLs.This class provides an implementation of an argument value validator that ensures that values can be parsed as valid object identifiers.This class provides an implementation of an argument value validator that is expected to be used with string or DN arguments and ensures that all values for the argument are valid DNs that are not within one or more specified subtrees.This class provides an implementation of an argument value validator that is expected to be used with a string argument and ensures that all values for the argument are valid regular expressions.This class provides an implementation of an argument value validator that is expected to be used with string or DN arguments and ensures that all values for the argument are valid DNs that are within one or more specified subtrees.This class defines an argument that is intended to hold one search scope values.This class defines an argument that is intended to hold one or more string values.This class provides a data structure that represents a subcommand that can be used in conjunction with the argument parser.This class defines an argument that is intended to hold one or more timestamp values.This class provides an implementation of an argument value validator that ensures that values must be timestamps (parsable by the
TimestampArgumentclass) within a specified time range.This class provides an implementation of an argument value validator that is expected to be used with a string argument and ensures that all values for the argument are valid URLs.