commandlineparser / commandlineparser/commandline

Values are not set properly wit multiple bool arguments

未关闭
#611 4 条评论 1 个 reaction 已指派 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; }
}

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。