Skip to content

ArgumentParser is not handling as expected option commands with the same name. #331

@didix21

Description

@didix21

After updating from Swift 5.3.1 to 5.4, I'm observing that the behaviour of how swift-argument-parser handle options with the same name from two different commands has changed. For example, If I run the following commands in Swift 5.3.1:

  • Swift 5.3.1
>> swift run --configuration debug shusky install --configuration ownconfig
output: "shusky configuration: ownconfig"
>> swift run shusky install --configuration ownconfig
output: "shusky configuration: ownconfig"

the result is swift run --configuration gets the value of debug, and shusky install --configuration gets ownconfig, but If I run the same commands in Swift 5.4:

  • Swift 5.4
>> swift run --configuration debug shusky install --configuration ownconfig
output: "error: The value 'ownconfig' is invalid for '--configuration <configuration>'"
>> swift run shusky install --configuration ownconfig
output: "error: The value 'ownconfig' is invalid for '--configuration <configuration>'"

as we can see, swift run --configuration gets the value of ownconfig for this reason is telling us ownconfig is invalid.

ArgumentParser version: 0.3.2
Swift version: Apple Swift version 5.4 (swiftlang-1205.0.26.9 clang-1205.0.19.55)
Target: arm64-apple-darwin20.5.0.

Checklist

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

Steps to Reproduce

You need a command line tool which contains options with similar names from swift run options, and then run:
swift run --configuration release <cli-tool> --configuration anyconf.

Expected behavior

Swift 5.4 must have the same behaviour as Swift 5.3.1.

Actual behavior

  • Swift 5.4
>> swift run --configuration debug shusky install --configuration ownconfig
output: "error: The value 'ownconfig' is invalid for '--configuration <configuration>'"
>> swift run shusky install --configuration ownconfig
output: "error: The value 'ownconfig' is invalid for '--configuration <configuration>'"

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions