commandlineparser / commandlineparser/commandline

Values are not set properly wit multiple bool arguments

Đang mở
#611 4 bình luận 1 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
C#
Star
4.8k
Fork
478
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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; }
}

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.