-
Notifications
You must be signed in to change notification settings - Fork 336
Unify @Argument and @Option initialization paths #477
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
5a1e4b7
to
b45568b
Compare
@swift-ci please test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great — thanks in particular for the extra test coverage 👏🏻👏🏻👏🏻
I don't feel like we have a great way to know exactly whether APIs are being introduced / removed here. I ran the breaking changes diagnostic, and after stripping some spurious errors (it doesn't think that changing the name a generic parameter is okay), I'm still seeing these four breaks — could you take a look to see if these are real or not?
💔 API breakage: constructor Argument.init(wrappedValue:parsing:help:completion:) has parameter 0 type change from Value to [Element]
💔 API breakage: constructor Argument.init(wrappedValue:parsing:help:completion:transform:) has parameter 0 type change from Value to [Element]
💔 API breakage: constructor Option.init(wrappedValue:name:parsing:help:completion:) has parameter 0 type change from [Element] to Value
💔 API breakage: constructor Option.init(wrappedValue:name:parsing:help:completion:transform:) has parameter 0 type change from [Element] to Value
Tests/ArgumentParserUnitTests/HelpGenerationTests+AtArgument.swift
Outdated
Show resolved
Hide resolved
HelpGenerationTests+AtArgument.swift | ||
HelpGenerationTests+AtOption.swift |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ᵗʰᵃⁿᵏ ʸᵒᵘ
- Fixes #466. - Adds initializers to ArgumentDefinition generic over a Container type. The Container type must conform to a new internal protocol ArgumentDefinitionContainer which describes functionality like default set of help options for the argument defined by the property wrapper, etc. - Adds overloads for Optional @arguments and @options with default values which emit deprecation warning to guide users towards using the non-Optional versions.
@natecook1000 those are all spurious AFAICT, I reran locally to verify again. |
@swift-ci please test |
1 similar comment
@swift-ci please test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚢
Due to the restructuring in #477, there was ambiguity between the unconstrained `@Option` initializer that uses a transform (but no initial value) and the one that is constrained to the property being optional. This marks the unconstrained version as disfavored, which allows overload resolution to select the optional version when appropriate. Fixes #618.
Due to the restructuring in #477, there was ambiguity between the unconstrained `@Option` initializer that uses a transform (but no initial value) and the one that is constrained to the property being optional. This marks the unconstrained version as disfavored, which allows overload resolution to select the optional version when appropriate. Also fixes this for `@Argument` and improves documentation consistency for `@Option`. Fixes #618.
transform:
parameter in@Argument
declaration generates wrong help message for optional arguments #466.The Container type must conform to a new internal protocol
ArgumentDefinitionContainer which describes functionality like default
set of help options for the argument defined by the property wrapper,
etc.
values which emit deprecation warning to guide users towards using the
non-Optional versions.