young
(rtSwift)
1
I want my command to work like this:
mytool --ios # do iOS
mytool --macos. # do macOS
mytool # must choose either --ios or --macos
I think this can be done with:
enum OSType: ExpressibleByArgument {
case ios, macos
init?(argument: String) {
if "ios" == argument {
self = .ios
} else if "macos" == argument {
self = .macos
} else {
return nil
}
}
}
// ... the in my command:
@Argument(help: "Enter either --ios or --macOS (<== this doesn't work, how to enter?")
var ostype: OSType
Am I doing the correctly? And how to use my Argument?
jjatie
2
You are implementing this correctly, but you're trying to pass it in as an option, not an argument. To run this from the command line, you want:
mytool ios # do iOS
mytool macos #do macOS
1 Like