apple / swift-argument-parser

Straightforward, type-safe argument parsing for Swift
Apache License 2.0
3.3k stars 311 forks source link

Extra values required with `--option=value` and `.upToNextOption` #609

Closed natecook1000 closed 8 months ago

natecook1000 commented 8 months ago

When an option is declared with the .upToNextOption parsing strategy, using a "tied" value isn't sufficient enough to satisfy the parser. For example, with this command declaration:

import ArgumentParser

@main
struct Example: ParsableCommand {
    @Option(name: .shortAndLong, parsing: .upToNextOption)
    var count: [Int] = []

    mutating func run() throws {
        print(count)
    }
}

The option requires at least one non-tied value:

$ example --count=1 1
[1, 1]
$ example --count=1
Error: Missing value for '--count <count>'
Help:  --count <count>
Usage: example [--count <count> ...]
  See 'example --help' for more information.

ArgumentParser version: 1.3.0 Swift version: Apple Swift version 5.11-dev (LLVM fe9a485647a386d, Swift e395df3ef372fd4)

Checklist