Add support for Void? flags#191
Add support for Void? flags#191MPLew-is wants to merge 1 commit intoapple:masterfrom MPLew-is:void-flags
Void? flags#191Conversation
This is intended to replace the `Bool` flag without an inversion, as it more closely matches the underlying usage model of a flag being provided vs. not provided on the command line.
| return ArgumentSet(arg) | ||
| } | ||
|
|
||
| static func flag(key: InputKey, name: NameSpecification, help: ArgumentHelp?, value: Void) -> ArgumentSet { |
There was a problem hiding this comment.
I'd also like to note that the value: Void argument is temporary, as the conflicting Bool-related flag method changes signature in #170, and this function would be flag(key:name:help:) after that.
|
Another side note is that my original idea here was to have a computed I also know the projected value would interfere with #128, but again this is mostly just first stab at something for the purposes of discussion. |
|
I don't think this is a change that we'll want to take. |
This is intended to replace the
Boolflag without an inversion, as it more closely matches the underlying usage model of a flag being provided vs. not provided on the command line.This is mostly a proof-of-concept proposal as a discussion point, relating to the discussion about no-inversion
Flags in #170. As a summary, this proposal is intended to address the behavior of flags without inversions:As discussed in the comment linked above, in my opinion, a
Booldoesn't represent the high-level usage model as well as anOptionaltype, especially with the usage ofBools in flags that have inversions and can be set by the user to have bothtrueandfalseas a value, not onlytrue. This PR proposes to replace the above usage with:This gains us the following benefits:
masterfalsefor every flag as currently on Allow normal Swift default property initialization syntax #170, while doing so in a Swift-like manner (since optionals already default tonil, users will be familiar with this usage pattern).prefixedNofor allBoolsHowever, this does come at a cost:
Void?may seem strange to users that aren't "cracking the hood" of this framework, so to speak, and will likely cause some confusion that needs to be sorted out in documentationtypealiasor single-caseenumas described in the initial discussion linked above, but I don't know of a great name for that either (Unary?)!= nilabove)I personally feel like those benefits are worth it, but I don't think there's an exceptionally strong case for it either like there was for the default property initialization syntax in #170. Mostly, I was just curious as to what it would take to implement this and provide a concrete implementation to start off dicussion.
Checklist