apple / apple/swift-argument-parser
Allow options to stop capturing if there are trailing arguments
- Dominant language
- Swift
- Stars
- 3.8k
- Forks
- 411
- Avg merge
- 7d 14h
- Merged PRs (30d)
- 15
Description
It would be good to be able to specify that an option should exclude catching trailing arguments. For example, it's quite common to have an option like:
`--option a b c`
but currently the only way to do this is to specify it should capture until the next `--` option is encountered. That means that if you have a trailing argument, like this:
`program command --option a b c filename.txt`
The trailing argument `filename.txt` will be captured by the option. This would be easy to implement by allowing any trailing arguments to capture "first", leaving the option to capture the remainder. In any case, if there are insufficient parameters, it will result in an error.
Contributor guide
Research direction
No files, tests, or entry points are named. Start by locating the option-capture and trailing-argument parsing logic, then define and test behavior for `program command --option a b c filename.txt`; done means the trailing filename is excluded while insufficient parameters still produce an error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100