Result struct
Result is a struct that is used to communicate between argparse and user functions. Its main responsibility is to hold the result of an operation: success or failure.
Public members
Success
Result.Success is an compile-time constant (enum) that represents a successful result of an operation.
Signature
Error
Result.Error is a function that returns a failed result of an operation.
Signature
Parameters
resultCodeResult/exit code of an operation.
msgText of an error message.
extraArgsAdditional arguments that are added to the text of an error message.
Notes
msgandextraArgsare converted to a single error message string usingstd.conv.text(msg, extraArgs).Error message supports ANSI styling. See ANSI coloring and styling how to use.
Error message is passed to
Config.errorHandlerif it's set or printed tostderrotherwise by CLI API at the end of parsing.
Return value
Result object that represents the failed result of an operation.
exitCode
Result.exitCode is a property that returns the result/exit code. It's supposed to be returned from main() function.
Signature
Return value
Result/exit code of an operation.
isSuccess
Result.isSuccess can be used to determine whether result of an operation is successful.
Signature
Return value
trueif operation is successful.falseotherwise.
isError
Result.isError can be used to determine whether result of an operation is error.
Signature
Return value
trueif the result is error.falseotherwise.
isHelpWanted
Result.isHelpWanted can be used to determine whether the help text was requested from command line (i.e. -h/--help argument was provided).
Signature
Return value
trueif help text was requested.falseotherwise.
opCast
Result.opCast is the same as Result.isSuccess.
Signature
Return value
trueif operation is successful.falseotherwise.