BSD style: see
license.txt
Initial release: December 2005
Lars Ivar Igesund, Eric Anderton
- alias void delegate (char[] value) ArgParserCallback ¶#
-
An alias to a delegate taking a char[] as a parameter. The value
parameter will hold any chars immediately
following the argument.
- alias void delegate (char[] value,uint ordinal) DefaultArgParserCallback ¶#
-
An alias to a delegate taking a char[] as a parameter. The value
parameter will hold any chars immediately
following the argument.
The ordinal argument represents which default argument this is for
the given stream of arguments. The first default argument will
be ordinal=0 with each successive call to this callback having
ordinal values of 1, 2, 3 and so forth. This can be reset to zero
in new calls to parse.
- alias void delegate () ArgParserSimpleCallback ¶#
-
An alias to a delegate taking no parameters
- struct Argument ¶#
-
A struct that represents a "{Prefix}{Identifier}" string.
- Argument opCall(char[] prefix, char[] identifier) [static] ¶#
-
Creates a new Argument instance with given prefix and identifier.
- alias Argument Arg ¶#
-
Alias for for the lazy people.
- class ArgParser ¶#
-
A utility class to parse and handle your command line arguments.
- struct PrefixCallback [protected] ¶#
-
A helper struct containing a callback and an id, corresponding to
the argId passed to one of the bind methods.
- void bind(char[] argPrefix, char[] argId, ArgParserCallback cb) [public] ¶#
-
Binds a delegate callback to argument with a prefix and
a argId.
argPrefix | the prefix of the argument, e.g. a dash '-'. |
argId | the name of the argument, what follows the prefix |
cb | the delegate that should be called when this argument is found |
- this() [public, deprecated] ¶#
-
The constructor, creates an empty ArgParser instance.
- this(DefaultArgParserCallback callback) [public, deprecated] ¶#
-
The constructor, creates an ArgParser instance with a defined default callback.
- void bind(char[] argPrefix, char[] argId, ArgParserSimpleCallback cb) [public] ¶#
-
Binds a delegate callback to argument with a prefix and
a argId.
argPrefix | the prefix of the argument, e.g. a dash '-'. |
argId | the name of the argument, what follows the prefix |
cb | the delegate that should be called when this argument is found |
- void bindDefault(char[] argPrefix, DefaultArgParserCallback callback) [public] ¶#
-
Binds a delegate callback to all arguments with prefix argPrefix, but that
do not conform to an argument bound in a call to bind().
argPrefix | the prefix for the callback |
callback | the default callback |
- void bindDefault(DefaultArgParserCallback callback) [public] ¶#
-
Binds a delegate callback to all arguments not conforming to an
argument bound in a call to bind(). These arguments will be passed to the
delegate without having any matching prefixes removed.
callback | the default callback |
- void bind(Argument argument, ArgParserCallback callback) [public] ¶#
-
Binds a delegate callback to an argument.
argument | argument to respond to |
callback | the delegate that should be called when the argument is found |
- void bind(Argument[] arguments, void delegate(char[]) callback) [public] ¶#
-
Binds a delegate callback to any number of arguments.
arguments | an array of Argument struct instances |
callback | the delegate that should be called when one of the arguments is found |
- void bindPosix(char[] identifier, ArgParserCallback callback) [public] ¶#
-
Binds a delegate callback to an identifier with Posix-like prefixes. This means,
it binds for both prefixes "-" and "--", as well as identifier with, and
without a delimiting "=" between identifier and value.
identifier | argument identifier |
callback | the delegate that should be called when one of the arguments is found |
- void bindPosix(char[][] identifiers, ArgParserCallback callback) [public] ¶#
-
Binds a delegate callback to any number of identifiers with Posix-like prefixes.
See bindPosix(identifier, callback).
arguments | an array of argument identifiers |
callback | the delegate that should be called when one of the arguments is found |
- void parse(char[][] arguments, bool resetOrdinals = false) [public] ¶#
-
Parses the arguments provided by the parameter. The bound callbacks are called as
arguments are recognized. If two arguments have the same prefix, and start with
the same characters (e.g.: --open, --opened), the longest matching bound callback
is called.
arguments | the command line arguments from the application |
resetOrdinals | if true, all ordinal counts will be set to zero |