Closed
Description
If you throw an error type that conforms to CustomNSError
from the run
method or a validation closure, the exit code of the program should be the one given by the custom error type's errorCode
property.
ArgumentParser version: main
branch
Swift version: Apple Swift version 5.3
Checklist
- If possible, I've reproduced the issue using the
main
branch of this package - I've searched for existing GitHub issues
Steps to Reproduce
Build and run this command, then use echo $?
(or echo $status
in fish) to inspect the exit code:
import ArgumentParser
import Foundation
enum CustomError: CustomNSError {
case error
var errorCode: Int {
switch self {
case .error: return 7
}
}
}
struct Example: ParsableCommand {
func run() throws {
throw CustomError.error
}
}
Example.main()
Expected behavior
The exit code should be 7.
Actual behavior
It's actually 1, aka EXIT_FAILURE
.
Activity