apple / apple/swift-argument-parser

Wrong error when providing an argument to an unknown option

Open
#23 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
3.8k
Forks
411
Avg merge
7d 13h
Merged PRs (30d)
17

Description

Given this argument parser:

```
fileprivate struct Qwz: ParsableArguments {
@Option() var name: String?
}
```

When I call it with `--nm Name`, I expect `Unknown option '--nm'`, but I get `Unexpected argument 'Name'`.

Failing test case:

```
extension ErrorMessageTests {
func testMispelledArgument_1() {
AssertErrorMessage(Qwz.self, ["--nme", "Me"], "Unknown option '--nme'.")
}
}
```

Contributor guide

Open the contributing guide

Research direction

Start with the ErrorMessageTests test case shown in the issue and run the parser with ["--nme", "Me"] against Qwz. Trace how the unknown option and its following value are classified. Done means the test reports "Unknown option '--nme'." rather than "Unexpected argument 'Me'."

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.