commandlineparser / commandlineparser/commandline

Values are not set properly wit multiple bool arguments

オープン
#611 コメント 4 件 リアクション 1 件 担当者 0 名 GitHub で見る
主要言語
C#
スター
4.8k
フォーク
478
PR マージ指標
30日以内にマージされた PR はありません

説明

I am passing 2 bool options, one on true and the other on false
But after being convert to the class all are true;

static void Main(string[] args)
{
args = new[] {"-p 88", "-t true", "-s false"};
var parseResult = Parser.Default.ParseArguments(args)
.WithParsed(o =>
{
Console.WriteLine($"PartnerId: -p {o.PartnerId}");
Console.WriteLine($"Test: -t {o.Test.ToString().ToLower()}");
Console.WriteLine($"SuppressEmail: -s {o.SuppressEmail.ToString().ToLower()}");
}
);
}
}

public class Options
{
[Option('p', "partnerId", Required = true, HelpText = "p = PartnerId")]
public int PartnerId { get; set; }

[Option('t', "test", HelpText = "Allows the app to be run on test mode, using only the allowed accounts")]
public bool Test { get; set; }

[Option('s', "suppressEmail", HelpText = "The app will not send the email to Post Up")]
public bool SuppressEmail { get; set; }
}

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

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

調査の方向性

Parser.Default.ParseArguments(args) とレポートに示されている Options クラスを使い、-t true と -s false を渡して問題を再現します。まず parser が bool 引数をどのように処理するかを追跡し、次に解析された Test と SuppressEmail の値が指定した引数と一致することを確認します。

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

評価

技術スタック
csharp
領域
cli
issue の種類
バグ
難易度
2/5
見積もり時間
1〜3時間
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

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

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