allUnrecognized

After parsing, capture all unrecognized inputs in this argument array.

Argument.swift:193
static var allUnrecognized: ArgumentArrayParsingStrategy { get }

You can use the allUnrecognized parsing strategy to suppress “unexpected argument” errors or to capture unrecognized inputs for further processing.

For example, the Example command defined below has an other array that uses the allUnrecognized parsing strategy:

@main
struct Example: ParsableCommand {
    @Flag var verbose = false
    @Argument var name: String

    @Argument(parsing: .allUnrecognized)
    var other: [String]

    func run() {
        print(other.joined(separator: "\n"))
    }
}

After parsing the --verbose flag and <name> argument, any remaining input is captured in the other array.

$ example --verbose Negin one two
one
two
$ example Asa --verbose --other -zzz
--other
-zzz