getCommandInfoFor

Generates a CommandInfo!CommandT populated with all the information about the command and its arguments.

Description: This template can be useful to gather information about a command and its argument, without having any extra baggage attached.

This allows you to introspect information about the command in the same way as JCLI does.

Members

Manifest constants

ArgInfoTuple
enum ArgInfoTuple;
Undocumented in source.
CommandDescription
enum CommandDescription;
Undocumented in source.
CommandDescription
enum CommandDescription;
Undocumented in source.
CommandPattern
enum CommandPattern;
Undocumented in source.
CommandPattern
enum CommandPattern;
Undocumented in source.
_dummy
enum _dummy;
Undocumented in source.
getCommandInfoFor
enum getCommandInfoFor;
Undocumented in source.

Parameters

CommandT

The Command to generate the information for.

ArgBinderInstance

The ArgBinder to use when generating argument setter functions.

Examples

import std.typecons : Nullable;

@Command("test", "doe")
static struct C
{
    @CommandNamedArg("abc", "123") string arg;
    @CommandPositionalArg(20, "ray", "me") @CommandArgGroup("nam") Nullable!bool pos;
    @CommandNamedArg @(CommandArgAction.count) int b;
}

enum info = getCommandInfoFor!(C, ArgBinder!());
static assert(info.pattern.matchSpaceless("test"));
static assert(info.description == "doe");
static assert(info.namedArgs.length == 2);
static assert(info.positionalArgs.length == 1);

static assert(info.namedArgs[0].identifier == "arg");
static assert(info.namedArgs[0].uda.pattern.matchSpaceless("abc"));
static assert(info.namedArgs[0].action == CommandArgAction.default_);
static assert(info.namedArgs[0].group == CommandArgGroup.init);
static assert(info.namedArgs[0].existence == CommandArgExistence.default_);
static assert(info.namedArgs[0].parseScheme == CommandArgParseScheme.default_);

static assert(info.positionalArgs[0].identifier == "pos");
static assert(info.positionalArgs[0].uda.position == 20);
static assert(info.positionalArgs[0].action == CommandArgAction.default_);
static assert(info.positionalArgs[0].group.name == "nam");
static assert(info.positionalArgs[0].existence == CommandArgExistence.optional);
static assert(info.positionalArgs[0].parseScheme == CommandArgParseScheme.bool_);

static assert(info.namedArgs[1].action == CommandArgAction.count);

Meta