remaining
Parse all remaining arguments into an array.
static var remaining: ArrayParsingStrategy { get }
.remaining
can be used for capturing pass-through flags. For example, for a parsable type defined as @Option(parsing: .remaining) var passthrough: [String]
:
$ cmd --passthrough --foo 1 --bar 2 -xvf
------------
options.passthrough == ["--foo", "1", "--bar", "2", "-xvf"]
Consider using a trailing @Argument
instead and letting users explicitly turn off parsing through the terminator --
. That is the more common approach. For example:
struct Options: ParsableArguments {
@Option var title: String
@Argument var remainder: [String]
}
would parse the input --title Foo -- Bar --baz
such that the remainder
would hold the value ["Bar", "--baz"]
.