From ddd45aa2e03d704161f44eab2ba985c51ff856c9 Mon Sep 17 00:00:00 2001 From: Nate Cook Date: Fri, 10 Sep 2021 18:30:09 -0500 Subject: [PATCH] Remove unavailable symbols (#354) --- .../Parsable Properties/Flag.swift | 91 ------------------- 1 file changed, 91 deletions(-) diff --git a/Sources/ArgumentParser/Parsable Properties/Flag.swift b/Sources/ArgumentParser/Parsable Properties/Flag.swift index 3415e5199..93d2f46e9 100644 --- a/Sources/ArgumentParser/Parsable Properties/Flag.swift +++ b/Sources/ArgumentParser/Parsable Properties/Flag.swift @@ -532,97 +532,6 @@ extension Flag { } } -// - MARK: Unavailable CaseIterable/RawValue == String - -extension Flag where Value: CaseIterable, Value: RawRepresentable, Value: Equatable, Value.RawValue == String { - /// Creates a property that gets its value from the presence of a flag, - /// where the allowed flags are defined by a case-iterable type. - /// - /// - Parameters: - /// - name: A specification for what names are allowed for this flag. - /// - initial: A default value to use for this property. If `initial` is - /// `nil`, this flag is required. - /// - exclusivity: The behavior to use when multiple flags are specified. - /// - help: Information about how to use this flag. - @available(*, unavailable, message: "Add 'EnumerableFlag' conformance to your value type and, if needed, specify the 'name' of each case there.") - public init( - name: NameSpecification = .long, - default initial: Value? = nil, - exclusivity: FlagExclusivity = .exclusive, - help: ArgumentHelp? = nil - ) { - self.init(_parsedValue: .init { key in - // This gets flipped to `true` the first time one of these flags is - // encountered. - var hasUpdated = false - let defaultValue = initial.map(String.init(describing:)) - - let args = Value.allCases.map { value -> ArgumentDefinition in - let caseKey = InputKey(rawValue: value.rawValue) - let help = ArgumentDefinition.Help(options: initial != nil ? .isOptional : [], help: help, defaultValue: defaultValue, key: key, isComposite: true) - return ArgumentDefinition.flag(name: name, key: key, caseKey: caseKey, help: help, parsingStrategy: .default, initialValue: initial, update: .nullary({ (origin, name, values) in - hasUpdated = try ArgumentSet.updateFlag(key: key, value: value, origin: origin, values: &values, hasUpdated: hasUpdated, exclusivity: exclusivity) - })) - } - return ArgumentSet(args) - }) - } -} - -extension Flag { - /// Creates a property that gets its value from the presence of a flag, - /// where the allowed flags are defined by a case-iterable type. - @available(*, unavailable, message: "Add 'EnumerableFlag' conformance to your value type and, if needed, specify the 'name' of each case there.") - public init( - name: NameSpecification = .long, - exclusivity: FlagExclusivity = .exclusive, - help: ArgumentHelp? = nil - ) where Value == Element?, Element: CaseIterable, Element: Equatable, Element: RawRepresentable, Element.RawValue == String { - self.init(_parsedValue: .init { key in - // This gets flipped to `true` the first time one of these flags is - // encountered. - var hasUpdated = false - - let args = Element.allCases.map { value -> ArgumentDefinition in - let caseKey = InputKey(rawValue: value.rawValue) - let help = ArgumentDefinition.Help(options: .isOptional, help: help, key: key, isComposite: true) - return ArgumentDefinition.flag(name: name, key: key, caseKey: caseKey, help: help, parsingStrategy: .default, initialValue: nil as Element?, update: .nullary({ (origin, name, values) in - hasUpdated = try ArgumentSet.updateFlag(key: key, value: value, origin: origin, values: &values, hasUpdated: hasUpdated, exclusivity: exclusivity) - })) - } - return ArgumentSet(args) - }) - } - - /// Creates an array property that gets its values from the presence of - /// zero or more flags, where the allowed flags are defined by a - /// `CaseIterable` type. - /// - /// This property has an empty array as its default value. - /// - /// - Parameters: - /// - name: A specification for what names are allowed for this flag. - /// - help: Information about how to use this flag. - @available(*, unavailable, message: "Add 'EnumerableFlag' conformance to your value type and, if needed, specify the 'name' of each case there.") - public init( - name: NameSpecification = .long, - help: ArgumentHelp? = nil - ) where Value == Array, Element: CaseIterable, Element: RawRepresentable, Element.RawValue == String { - self.init(_parsedValue: .init { key in - let args = Element.allCases.map { value -> ArgumentDefinition in - let caseKey = InputKey(rawValue: value.rawValue) - let help = ArgumentDefinition.Help(options: .isOptional, help: help, key: key, isComposite: true) - return ArgumentDefinition.flag(name: name, key: key, caseKey: caseKey, help: help, parsingStrategy: .default, initialValue: [Element](), update: .nullary({ (origin, name, values) in - values.update(forKey: key, inputOrigin: origin, initial: [Element](), closure: { - $0.append(value) - }) - })) - } - return ArgumentSet(args) - }) - } -} - extension ArgumentDefinition { static func flag(name: NameSpecification, key: InputKey, caseKey: InputKey, help: Help, parsingStrategy: ArgumentDefinition.ParsingStrategy, initialValue: V?, update: Update) -> ArgumentDefinition { return ArgumentDefinition(kind: .name(key: caseKey, specification: name), help: help, completion: .default, parsingStrategy: parsingStrategy, update: update, initial: { origin, values in