Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify postTerminator parsing strategy behavior #621

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions Sources/ArgumentParser/Parsable Properties/Argument.swift
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ public struct ArgumentArrayParsingStrategy: Hashable {
self.init(base: .allUnrecognized)
}

/// Before parsing, capture all inputs that follow the `--` terminator in this
/// argument array.
/// Before parsing arguments, capture all inputs that follow the `--`
/// terminator in this argument array.
///
/// For example, the `Example` command defined below has a `words` array that
/// uses the `postTerminator` parsing strategy:
Expand Down Expand Up @@ -219,6 +219,14 @@ public struct ArgumentArrayParsingStrategy: Hashable {
/// Error: Unexpected argument 'Extra'
/// ```
///
/// Because options are parsed before arguments, an option that consumes or
/// suppresses the `--` terminator can prevent a `postTerminator` argument
/// array from capturing any input. In particular, the
/// ``SingleValueParsingStrategy/unconditional``,
/// ``ArrayParsingStrategy/unconditionalSingleValue``, and
/// ``ArrayParsingStrategy/remaining`` parsing strategies can all consume
/// the terminator as part of their values.
///
/// - Note: This parsing strategy can be surprising for users, since it
/// changes the behavior of the `--` terminator. Prefer ``remaining``
/// whenever possible.
Expand Down