dotnet / dotnet/command-line-api

Support POSIX-style argument unbundling for `/`-prefixed, multi-character options (Was: Parser does not support options that have no seperator)

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

Description

While working on a project to parse the MSVC compiler (cl.exe's) options, I discovered that options that do not have a separator (such as the compiler's /AI option) cannot be parsed.

https://docs.microsoft.com/en-us/cpp/build/reference/ai-specify-metadata-directories?view=msvc-170

@jonsequitur confirmed this behavior with this response:

System.CommandLine is intended to be able to handle a larger number of command line grammars than is typical in one parser because we wanted to cover every common Windows as well as POSIX convention. You can see a bunch of examples below. But while we did cover the case where no space is needed between the option name and argument for POSIX-style bundling, we hadn’t seen this convention used for Windows-style command lines. What’s happening here is that for /AIHello we’re not looking for an undelimited argument because it’s not using a dash prefix, and for -AIHello, we’re not looking for an undelimited argument because -A and -I are not independently valid tokens that can be unbundled. We can take a closer look and see if this is a bug and what it would take to support these conventions.

![image](https://user-images.githubusercontent.com/6741868/160184837-9a1fb536-1b1d-4bc0-a534-d958c4d1f15f.png)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.