Add an EnumerableFlag protocol#65
Conversation
This addresses the need for providing name specifications for enum flags, since property wrappers can't be used for enum cases.
b73d66d to
6576bbc
Compare
|
@swift-ci Please test |
Co-authored-by: Kyle Macomber <kmacomber@apple.com>
|
At first I thought the Array case was counter intuitive: enum Color: EnumerableFlag {
case pink, purple, silver
}
struct Example: ParsableCommand {
@Flag() var colors: [Color]
func run() throws {
print(colors)
}
}... and was going to suggest it be broken out into a separate property wrapper, but I see the synergy with the Int use case. |
|
Seems like we could accept any |
We could definitely make these generic over |
|
@swift-ci Please test |
Description
This addresses the need for providing name specifications for
enumflags, since property wrappers can't be used for enumeration cases.Detailed Design
This includes a new
EnumerableFlagprotocol:As well as new
EnumerableFlag-constrained@Flaginitializers that replace the current ones that are constrained toString/CaseIterable.Documentation Plan
Wrote type- and symbol-level documentation for
EnumerableFlag, revised docs for the new initializers, and updated the "Argument, Options, and Flags" guide.Test Plan
Modified unit tests to use the new protocol and added tests that use the original, deprecated versions.
Source Impact
This deprecates the
@Flaginitializers that are constrained toCaseIterable/RawRepresentableandRawValue == String. These initializers will continue to work, and can be removed in a future version.Checklist