Skip to content

Avoid false duplicate detection for repeated --batch options without values #651

Description

@Seddryck

Problem

System.CommandLine tokenizes --batch=a into an option identifier and an argument, so repeated equals syntax is counted correctly.

However, this command:

run "trim" --batch --batch

can treat the second --batch token as the first option's value. A raw token count therefore counts both occurrences and incorrectly reports a duplicate option.

Expected behavior

Duplicate detection should use the parsed option result rather than raw tokens.

Use:

result.GetResult(batch)?.IdentifierTokenCount ?? 0

so only actual option identifiers are counted.

Acceptance criteria

  • --batch=a --batch=b is still detected as a duplicate when duplicates are not allowed.
  • --batch --batch does not produce a false duplicate solely because the second token was parsed as the first option's value.
  • Add regression tests covering both equals syntax and repeated bare option tokens.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions