dotnet / dotnet/command-line-api

Option with non-eager optional argument, like --backup[=CONTROL]

Open
#2,072 3 comments 0 reactions 0 assignees View on GitHub
Area-Parser and Binder bug
Dominant language
C#
Stars
3.7k
Forks
428
PR merge metrics
No merged PRs in 30d

Description

In GNU `getopt_long`, if an option has an optional argument, then it has to be in the same element of `char *argv[]`, connected with an equals sign. Thus, `numbered` is parsed as the argument of the option in `cp --backup=numbered source directory/` but as a separate argument (and treated as a file name) in `cp --backup numbered source directory/`. AFAICT, System.CommandLine cannot be configured to behave this way.

Contributor guide

Open the contributing guide

Research direction

Start by comparing System.CommandLine's optional-argument parsing with GNU getopt_long behavior described in the issue, especially the distinction between --backup=numbered and --backup numbered. Trace the parser entry points and existing tests, then add coverage showing that an optional argument is accepted only when attached with an equals sign, while the separate token remains a positional argument.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
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.