ArgBinder.bind

Binds the given arg to the value, using the @ArgBinderFunc found by using the 'Lookup Rules' documented in the document comment for ArgBinder.

More...
struct ArgBinder(Modules...)
static
bind
(
T
UDAs...
)
(
string arg
)

Parameters

arg string

The argument to bind.

UDAs

A tuple of UDA structs to use.

Detailed Description

Validators

The UDAs template parameter is used to pass in different UDA structs, including validator structs (see ArgBinder's documentation comment).

Anything inside of this template parameter that isn't a struct, and doesn't have the ArgValidator UDA will be completely ignored, so it is safe to simply pass the results of __traits(getAttributes, someField) without having to worry about filtering.

Specific Binders

The UDAs template paramter is used to pass in different UDA structs, including the ArgBindWith UDA.

If the ArgBindWith UDA exists within the given parameter, arg binding will be performed using the function provided by ArgBindWith, instead of using the default lookup rules defined by ArgBinder.

For example, say you have a several File arguments that need different binding behaviour (some are read-only, some truncate, etc.) In a case like this, you could have some of those arguments marked with @ArgBindWith!openFileReadOnly and others with a function for truncating, etc.

Throws

Exception if any validator fails.

Assertions: When an @ArgBinderFunc is found, it must have only 1 parameter.

The first parameter of an @ArgBinderFunc must be a string.

It must return an instance of the Result struct. It is recommended to use Result!void as the result's Success.value is ignored.

If no appropriate binder func was found, then an assert(false) is used.

If @ArgBindWith exists, then exactly 1 must exist, any more than 1 is an error.

Meta