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
resultCode
Result/exit code of an operation. If it's not specified then
1
is used.msg
Text of an error message.
extraArgs
Additional arguments that are added to the text of an error message.
Notes
msg
andextraArgs
are 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.errorHandler
if it's set or printed tostderr
otherwise 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.
opCast
Result.opCast
can be used to determine whether result of an operation is successful.
Signature
Return value
true
if operation is successful.false
otherwise.