Skip to content

Commit ddd45aa

Browse files
authored
Remove unavailable symbols (#354)
1 parent b77ea81 commit ddd45aa

File tree

1 file changed

+0
-91
lines changed
  • Sources/ArgumentParser/Parsable Properties

1 file changed

+0
-91
lines changed

Sources/ArgumentParser/Parsable Properties/Flag.swift

Lines changed: 0 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -532,97 +532,6 @@ extension Flag {
532532
}
533533
}
534534

535-
// - MARK: Unavailable CaseIterable/RawValue == String
536-
537-
extension Flag where Value: CaseIterable, Value: RawRepresentable, Value: Equatable, Value.RawValue == String {
538-
/// Creates a property that gets its value from the presence of a flag,
539-
/// where the allowed flags are defined by a case-iterable type.
540-
///
541-
/// - Parameters:
542-
/// - name: A specification for what names are allowed for this flag.
543-
/// - initial: A default value to use for this property. If `initial` is
544-
/// `nil`, this flag is required.
545-
/// - exclusivity: The behavior to use when multiple flags are specified.
546-
/// - help: Information about how to use this flag.
547-
@available(*, unavailable, message: "Add 'EnumerableFlag' conformance to your value type and, if needed, specify the 'name' of each case there.")
548-
public init(
549-
name: NameSpecification = .long,
550-
default initial: Value? = nil,
551-
exclusivity: FlagExclusivity = .exclusive,
552-
help: ArgumentHelp? = nil
553-
) {
554-
self.init(_parsedValue: .init { key in
555-
// This gets flipped to `true` the first time one of these flags is
556-
// encountered.
557-
var hasUpdated = false
558-
let defaultValue = initial.map(String.init(describing:))
559-
560-
let args = Value.allCases.map { value -> ArgumentDefinition in
561-
let caseKey = InputKey(rawValue: value.rawValue)
562-
let help = ArgumentDefinition.Help(options: initial != nil ? .isOptional : [], help: help, defaultValue: defaultValue, key: key, isComposite: true)
563-
return ArgumentDefinition.flag(name: name, key: key, caseKey: caseKey, help: help, parsingStrategy: .default, initialValue: initial, update: .nullary({ (origin, name, values) in
564-
hasUpdated = try ArgumentSet.updateFlag(key: key, value: value, origin: origin, values: &values, hasUpdated: hasUpdated, exclusivity: exclusivity)
565-
}))
566-
}
567-
return ArgumentSet(args)
568-
})
569-
}
570-
}
571-
572-
extension Flag {
573-
/// Creates a property that gets its value from the presence of a flag,
574-
/// where the allowed flags are defined by a case-iterable type.
575-
@available(*, unavailable, message: "Add 'EnumerableFlag' conformance to your value type and, if needed, specify the 'name' of each case there.")
576-
public init<Element>(
577-
name: NameSpecification = .long,
578-
exclusivity: FlagExclusivity = .exclusive,
579-
help: ArgumentHelp? = nil
580-
) where Value == Element?, Element: CaseIterable, Element: Equatable, Element: RawRepresentable, Element.RawValue == String {
581-
self.init(_parsedValue: .init { key in
582-
// This gets flipped to `true` the first time one of these flags is
583-
// encountered.
584-
var hasUpdated = false
585-
586-
let args = Element.allCases.map { value -> ArgumentDefinition in
587-
let caseKey = InputKey(rawValue: value.rawValue)
588-
let help = ArgumentDefinition.Help(options: .isOptional, help: help, key: key, isComposite: true)
589-
return ArgumentDefinition.flag(name: name, key: key, caseKey: caseKey, help: help, parsingStrategy: .default, initialValue: nil as Element?, update: .nullary({ (origin, name, values) in
590-
hasUpdated = try ArgumentSet.updateFlag(key: key, value: value, origin: origin, values: &values, hasUpdated: hasUpdated, exclusivity: exclusivity)
591-
}))
592-
}
593-
return ArgumentSet(args)
594-
})
595-
}
596-
597-
/// Creates an array property that gets its values from the presence of
598-
/// zero or more flags, where the allowed flags are defined by a
599-
/// `CaseIterable` type.
600-
///
601-
/// This property has an empty array as its default value.
602-
///
603-
/// - Parameters:
604-
/// - name: A specification for what names are allowed for this flag.
605-
/// - help: Information about how to use this flag.
606-
@available(*, unavailable, message: "Add 'EnumerableFlag' conformance to your value type and, if needed, specify the 'name' of each case there.")
607-
public init<Element>(
608-
name: NameSpecification = .long,
609-
help: ArgumentHelp? = nil
610-
) where Value == Array<Element>, Element: CaseIterable, Element: RawRepresentable, Element.RawValue == String {
611-
self.init(_parsedValue: .init { key in
612-
let args = Element.allCases.map { value -> ArgumentDefinition in
613-
let caseKey = InputKey(rawValue: value.rawValue)
614-
let help = ArgumentDefinition.Help(options: .isOptional, help: help, key: key, isComposite: true)
615-
return ArgumentDefinition.flag(name: name, key: key, caseKey: caseKey, help: help, parsingStrategy: .default, initialValue: [Element](), update: .nullary({ (origin, name, values) in
616-
values.update(forKey: key, inputOrigin: origin, initial: [Element](), closure: {
617-
$0.append(value)
618-
})
619-
}))
620-
}
621-
return ArgumentSet(args)
622-
})
623-
}
624-
}
625-
626535
extension ArgumentDefinition {
627536
static func flag<V>(name: NameSpecification, key: InputKey, caseKey: InputKey, help: Help, parsingStrategy: ArgumentDefinition.ParsingStrategy, initialValue: V?, update: Update) -> ArgumentDefinition {
628537
return ArgumentDefinition(kind: .name(key: caseKey, specification: name), help: help, completion: .default, parsingStrategy: parsingStrategy, update: update, initial: { origin, values in

0 commit comments

Comments
 (0)