commandlineparser / commandlineparser/commandline

Join IEnumerable defaults with separator instead of space

未關閉 適合新手
#951 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
C#
星號
4.8k
分支
478
PR 合併指標
30 天內沒有已合併 PR

描述

Source:
```cs
#:package CommandLineParser@2.9.1

using CommandLine;

return Parser.Default.ParseArguments(args).MapResult(
(Opts opts) => 0,
errors => 2
);

class Opts {
[Option("opt", Required = true, Separator = ',', Default = new[] { "AAA", "BBB", "CCC" }, HelpText = "boolean arg.")]
public IEnumerable MyOption { get; set; }
}
```

Output with `--help`:
```
test_cmdline 1.0.0
Copyright (C) 2026 test_cmdline

--opt Required. (Default: AAA BBB CCC) boolean arg.

--help Display this help screen.

--version Display version information.
```

Notice that the default argument's values are joined by spaces, which is misleading.
Since a separator is provided it should be used instead, so that the user could just copy-paste the resulting value directly and use it as argument. Currently there is no way to achieve this: see [here](https://github.com/commandlineparser/commandline/blob/1e3607b97af6141743edb3c434c06d5b492f6fb3/src/CommandLine/Text/HelpText.cs#L1125).

貢獻指南

這個儲存庫沒有索引到貢獻指南

研究方向

Start in src/CommandLine/Text/HelpText.cs around line 1125, where default IEnumerable values are formatted for help output. Trace how the option's configured separator is available during formatting, then verify the sample's --help output uses commas between AAA, BBB, and CCC so the displayed default can be copied as an argument.

由索引模型根據 Issue 內容生成。

評估

技術堆疊
csharp
領域
cli
Issue 類型
缺陷
難度
2/5
預估耗時
1-3 小時
活躍度
冷清
描述清晰度
描述清楚
新手友好度
68/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。