SubCommand
SubCommand type can be used to enumerate type for subcommands. This is a wrapper of SumType:
Public members
Copy constructor
Signature
Parameters
T valueValue that is copied to a new object. Its type
Tmust be one of theCommands.
Assignment operator
Signature
Parameters
T valueValue to be assigned. Its type
Tmust be one of theCommands.
isSetTo
Checks whether the object is set to a specific command type;
Signature
Parameters
TType
Tmust 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:
trueif object contains any type fromCommands,falseotherwise.
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
matchCmd
matchCmd is a function template that is similar to std.sumtype.match but adapted to work with SubCommand.
Signature
Parameters
handlersFunctions that have the same meaning as for
matchCmdfunction in standard library with an exception that they must not useDefaulttype because the latter is erased bySubCommand(i.e. just useTinstead ofDefault!There).scSubCommandparameter that the matching is applied to.
Return value
If
scis set to any subcommand (or has default one) then function returns the result fromstd.sumtype.matchfunction.Otherwise,
initvalue of the type that would be returned fromstd.sumtype.matchfunction if that type is notvoid.Otherwise, this function has no return value (i.e. it's
void).