-
Notifications
You must be signed in to change notification settings - Fork 352
Description
As documented, the . unconditionalRemaining parsing mode includes -- and any following tokens, when used in a root command. However, in subcommands, the -- is skipped (but the following arguments are included).
ArgumentParser version: 0.0.5 and master
Swift version: Apple Swift version 5.1.3 (swiftlang-1100.0.282.1 clang-1100.0.33.15)
Checklist
- If possible, I've reproduced the issue using the
masterbranch of this package - I've searched for existing GitHub issues
Steps to Reproduce
This code is adapted from the section Alternative positional argument parsing strategies in the documentation. It adds parsing: .unconditionalRemaining and also wraps the example command so it acts as a subcommand.
import ArgumentParser
struct Example: ParsableCommand {
@Flag() var verbose: Bool
@Argument(parsing: .unconditionalRemaining) var files: [String]
func run() throws {
print("Verbose: \(verbose), files: \(files)")
}
}
struct Wrapper: ParsableCommand {
static let configuration = CommandConfiguration(
abstract: "yes",
subcommands: [
Example.self
]
)
}
Wrapper.main()Expected behavior
When invoked as wrapper example --verbose file1.swift -- file2.swift --other, it should print:
Verbose: true, files: ["file1.swift", "--", "file2.swift", "--other"]
Actual behavior
It actually prints:
Verbose: true, files: ["file1.swift", "file2.swift", "--other"]
Note that if we replace Wrapper.main() with Example.main() (and remove example from the invocation), it works as expected.