commandlineparser / commandlineparser/commandline

Join IEnumerable defaults with separator instead of space

オープン 初心者向け
#951 コメント 1 件 リアクション 0 件 担当者 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).

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

src/CommandLine/Text/HelpText.cs の 1125 行目付近から始めます。ここでは、ヘルプ出力用にデフォルトの IEnumerable 値がフォーマットされています。フォーマット中にオプションの設定済みの区切り文字がどのように利用可能かを追跡し、その後、サンプルの --help 出力で AAA、BBB、CCC の間にカンマが使用され、表示されたデフォルト値を引数としてコピーできることを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
csharp
領域
cli
issue の種類
バグ
難易度
2/5
見積もり時間
1〜3時間
活発さ
静か
明瞭さ
明確に書かれている
初心者へのやさしさ
68/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。