apple / apple/swift-argument-parser

Allow options to stop capturing if there are trailing arguments

Open
#106 1 comment 2 reactions 0 assignees View on GitHub
enhancement
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.