SubCommand
SubCommand
type can be used to enumerate type for subcommands. This is a wrapper of SumType
:
Public members
Copy constructor
Signature
Parameters
T value
Value that is copied to a new object. Its type
T
must be one of theCommands
.
Assignment operator
Signature
Parameters
T value
Value to be assigned. Its type
T
must be one of theCommands
.
isSetTo
Checks whether the object is set to a specific command type;
Signature
Parameters
T
Type
T
must be one of theCommands
.
Return value
true
if object contains T
type, false
otherwise.
isSet
Checks whether the object is set to any command type;
Signature
Return value
If one of the Commands
is a default command then this function always returns true
.
In case if there is no default command, then:
true
if object contains any type fromCommands
,false
otherwise.
Default
Default
type is a struct that can be used to mark a subcommand as default, i.e. it's chosen if no other subcommand is specified in command line explicitly.
This struct has no members and is erased by SubCommand
before passing to internal SumType
member.
Signature
match
match
is a function template that is similar to the one from standard library but adapted to work with SubCommand
.
Signature
Parameters
handlers
Functions that have the same meaning as for
match
function in standard library with an exception that they must not useDefault
type because the latter is erased bySubCommand
(i.e. just useT
instead ofDefault!T
here).sc
SubCommand
parameter that the matching is applied to.
Return value
If
SubCommand
is set to any subcommand (or has default one) then function returns the result frommatch
function from standard library.Otherwise,
init
value of the type that would be returned frommatch
function from standard library if that type is notvoid
.Otherwise, this function has no return value (i.e. it's
void
).