Skip to content

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

@natecook1000

Description

@natecook1000

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

  • If possible, I've reproduced the issue using the main branch of this package
  • I've searched for existing GitHub issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions