Skip to content

Repeated flags with FlagExclusivity.chooseFirst error instead of choosing first. #66

@glessard

Description

@glessard

Repeated flags defined with FlagExclusivity.chooseFirst error instead of choosing first.

ArgumentParser version: master at 58660b0
Swift version: Apple Swift version 5.2 (swiftlang-1103.0.30 clang-1103.0.30)

Checklist

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

Steps to Reproduce

Use this simple program:

enum Enum: String, CaseIterable { case s, t, u }

struct Options: ParsableCommand {
  @Flag(name: .short, exclusivity: .chooseFirst)
  var flag1: Enum
}

let options = Options.parseOrExit()
print(options.flag1)
$ options -s -t

Expected behavior

It should print "s" by itself, on a line

Actual behavior

$ options -s -t
Error: Unknown option '-t'
Usage: options -s -t -u

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