Open
Description
Currently it's only possible to use initial value if the property type is non-Optional
.
I'd like to use environment variable as a fallback value for a command line argument (similar how it's done in Fastlane), but keep the argument required. To allow this I'd like to propose adding the initial
argument to initializers of non-Optional
type property wrappers which do not contain the wrappedValue
argument.
For example adjusting the Option
initializer:
public init(
name: NameSpecification = .long,
parsing parsingStrategy: SingleValueParsingStrategy = .next,
help: ArgumentHelp? = nil,
completion: CompletionKind? = nil,
initial: Value? = nil // <-- Using default value preserves backward compatibility
) {
self.init(_parsedValue: .init { key in
let arg = ArgumentDefinition(
container: Bare<Value>.self,
key: key,
kind: .name(key: key, specification: name),
help: help,
parsingStrategy: parsingStrategy.base,
initial: initial, // <-- injecting the initial value
completion: completion)
return ArgumentSet(arg)
})
would allow us to use it as follows:
@Option(initial: ProcessInfo.processInfo["REQUIRED_OPTION"])
var requiredOption: String
Metadata
Metadata
Assignees
Labels
No labels