Skip to content

Commit dc75893

Browse files
committed
Deprecate Option initializer and add a new one with parameters in order
1 parent 403d34d commit dc75893

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

Sources/ArgumentParser/Parsable Properties/Option.swift

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,40 @@ extension Option where Value: ExpressibleByArgument {
138138
/// - name: A specification for what names are allowed for this flag.
139139
/// - parsingStrategy: The behavior to use when looking for this option's value.
140140
/// - help: Information about how to use this option.
141+
@available(*, deprecated, message: "Use init(wrappedValue:name:parsing:help:completion:) instead.")
141142
public init(
142143
wrappedValue: Value,
143144
name: NameSpecification = .long,
144145
parsing parsingStrategy: SingleValueParsingStrategy = .next,
145-
completion: CompletionKind? = nil,
146-
help: ArgumentHelp? = nil
146+
completion: CompletionKind,
147+
help: ArgumentHelp
148+
) {
149+
self.init(
150+
name: name,
151+
initial: wrappedValue,
152+
parsingStrategy: parsingStrategy,
153+
help: help,
154+
completion: completion)
155+
}
156+
157+
/// Creates a property with a default value provided by standard Swift default value syntax.
158+
///
159+
/// This method is called to initialize an `Option` with a default value such as:
160+
/// ```swift
161+
/// @Option var foo: String = "bar"
162+
/// ```
163+
///
164+
/// - Parameters:
165+
/// - wrappedValue: A default value to use for this property, provided implicitly by the compiler during property wrapper initialization.
166+
/// - name: A specification for what names are allowed for this flag.
167+
/// - parsingStrategy: The behavior to use when looking for this option's value.
168+
/// - help: Information about how to use this option.
169+
public init(
170+
wrappedValue: Value,
171+
name: NameSpecification = .long,
172+
parsing parsingStrategy: SingleValueParsingStrategy = .next,
173+
help: ArgumentHelp? = nil,
174+
completion: CompletionKind? = nil
147175
) {
148176
self.init(
149177
name: name,

0 commit comments

Comments
 (0)