Skip to content

Commit

Permalink
Deprecate Option initializer and add a new one with parameters in order
Browse files Browse the repository at this point in the history
  • Loading branch information
McNight committed Jan 17, 2022
1 parent 403d34d commit dc75893
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions Sources/ArgumentParser/Parsable Properties/Option.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,40 @@ 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.
@available(*, deprecated, message: "Use init(wrappedValue:name:parsing:help:completion:) instead.")
public init(
wrappedValue: Value,
name: NameSpecification = .long,
parsing parsingStrategy: SingleValueParsingStrategy = .next,
completion: CompletionKind? = nil,
help: ArgumentHelp? = nil
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:
/// ```swift
/// @Option var foo: String = "bar"
/// ```
///
/// - Parameters:
/// - wrappedValue: A default value to use for this property, provided implicitly by the compiler during property wrapper initialization.
/// - 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.
public init(
wrappedValue: Value,
name: NameSpecification = .long,
parsing parsingStrategy: SingleValueParsingStrategy = .next,
help: ArgumentHelp? = nil,
completion: CompletionKind? = nil
) {
self.init(
name: name,
Expand Down

0 comments on commit dc75893

Please sign in to comment.