-
Notifications
You must be signed in to change notification settings - Fork 330
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
Deprecate Option initializer and add a new one with parameters in order #391
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,6 +126,23 @@ extension Option where Value: ExpressibleByArgument { | |
) | ||
} | ||
|
||
/// Creates a property with a default value provided by standard Swift default value syntax. | ||
@available(*, deprecated, message: "Swap the order of your 'help' and 'completion' arguments.") | ||
public init( | ||
wrappedValue: Value, | ||
name: NameSpecification = .long, | ||
parsing parsingStrategy: SingleValueParsingStrategy = .next, | ||
completion: CompletionKind?, | ||
help: ArgumentHelp? | ||
) { | ||
self.init( | ||
name: name, | ||
initial: wrappedValue, | ||
parsingStrategy: parsingStrategy, | ||
help: help, | ||
completion: completion) | ||
} | ||
|
||
/// Creates a property with a default value provided by standard Swift default value syntax. | ||
/// | ||
/// This method is called to initialize an `Option` with a default value such as: | ||
|
@@ -138,12 +155,13 @@ extension Option where Value: ExpressibleByArgument { | |
/// - name: A specification for what names are allowed for this flag. | ||
/// - parsingStrategy: The behavior to use when looking for this option's value. | ||
/// - help: Information about how to use this option. | ||
/// - completion: Kind of completion provided to the user for this option. | ||
public init( | ||
wrappedValue: Value, | ||
name: NameSpecification = .long, | ||
parsing parsingStrategy: SingleValueParsingStrategy = .next, | ||
completion: CompletionKind? = nil, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change isn't ABI stable if I recall correctly, but im not sure if that matters for this library. I wonder if you could leave types as Optional with a default of @natecook1000 to comment on if this is necessary There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't know about There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need to worry about ABI stability, since this isn't shipping as a binary library, but for source stability we need the parameter types to stay the same. The default values can go, however, which should be enough to prevent ambiguity between this deprecated version and the new one. |
||
help: ArgumentHelp? = nil | ||
help: ArgumentHelp? = nil, | ||
completion: CompletionKind? = nil | ||
) { | ||
self.init( | ||
name: name, | ||
|
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.
Could you add a description of the
completion
parameter?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.
Sure!
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.
Fixed. I noticed that a lot of
completionKind
parameters from other initializers are not documented. What should we do about those ?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.
Probably worth doing in a separate pull request (if you're up to it)