init(name:parsing:help:completion:transform:)

Creates a required property that reads its value from a labeled option, parsing with the given closure.

Option.swift:433
@preconcurrency init(name: NameSpecification = .long, parsing parsingStrategy: SingleValueParsingStrategy = .next, help: ArgumentHelp? = nil, completion: CompletionKind? = nil, transform: @escaping (String) throws -> Value)

Parameters

name

A specification for what names are allowed for this option.

parsingStrategy

The behavior to use when looking for this option’s value.

help

Information about how to use this option.

completion

The type of command-line completion provided for this option.

transform

A closure that converts a string into this property’s type, or else throws an error.

This initializer is used when you declare an @Option-attributed property with a transform closure and without a default value:

@Option(transform: { $0.first ?? " " })
var char: Character