Skip to content

Commit f674173

Browse files
authored
Don't let .allUnrecognized consume built-in flags (#550)
Arguments declared with the `.allUnrecognized` parsing strategy currently capture built-in flags, which isn't intended. This fixes that issue by looking for built-in flags in the captured portion of the input before decoding. Fixes rdar://104990388
1 parent a9b9644 commit f674173

File tree

6 files changed

+332
-275
lines changed

6 files changed

+332
-275
lines changed

Sources/ArgumentParser/Parsable Types/ParsableCommand.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,17 +165,23 @@ extension ParsableCommand {
165165
extension ParsableCommand {
166166
/// `true` if this command contains any array arguments that are declared
167167
/// with `.unconditionalRemaining`.
168-
internal static var includesUnconditionalArguments: Bool {
168+
internal static var includesPassthroughArguments: Bool {
169169
ArgumentSet(self, visibility: .private, parent: nil).contains(where: {
170170
$0.isRepeatingPositional && $0.parsingStrategy == .allRemainingInput
171171
})
172172
}
173173

174+
internal static var includesAllUnrecognizedArgument: Bool {
175+
ArgumentSet(self, visibility: .private, parent: nil).contains(where: {
176+
$0.isRepeatingPositional && $0.parsingStrategy == .allUnrecognized
177+
})
178+
}
179+
174180
/// `true` if this command's default subcommand contains any array arguments
175181
/// that are declared with `.unconditionalRemaining`. This is `false` if
176182
/// there's no default subcommand.
177-
internal static var defaultIncludesUnconditionalArguments: Bool {
178-
configuration.defaultSubcommand?.includesUnconditionalArguments == true
183+
internal static var defaultIncludesPassthroughArguments: Bool {
184+
configuration.defaultSubcommand?.includesPassthroughArguments == true
179185
}
180186

181187
#if DEBUG

0 commit comments

Comments
 (0)