Fix boolean command line parsing from int
This commit is contained in:
@@ -149,6 +149,12 @@ namespace Flax.Build.Tests
|
||||
CommandLine.Configure(typeof(TestConfig1), "-option1 -option");
|
||||
Assert.AreEqual(true, TestConfig1.Option1);
|
||||
|
||||
CommandLine.Configure(typeof(TestConfig1), "-option1=0");
|
||||
Assert.AreEqual(false, TestConfig1.Option1);
|
||||
|
||||
CommandLine.Configure(typeof(TestConfig1), "-option1=TRUE");
|
||||
Assert.AreEqual(true, TestConfig1.Option1);
|
||||
|
||||
CommandLine.Configure(typeof(TestConfig1), "-option2=11");
|
||||
Assert.AreEqual(11, TestConfig1.Option2);
|
||||
|
||||
|
||||
@@ -462,10 +462,14 @@ namespace Flax.Build
|
||||
try
|
||||
{
|
||||
// Implicit casting to boolean value
|
||||
if (type == typeof(bool) && string.IsNullOrEmpty(option.Value))
|
||||
if (type == typeof(bool) && (string.IsNullOrEmpty(option.Value) || option.Value == "1"))
|
||||
{
|
||||
value = true;
|
||||
}
|
||||
else if (type == typeof(bool) && option.Value == "0")
|
||||
{
|
||||
value = false;
|
||||
}
|
||||
// Arrays handling
|
||||
else if (type.IsArray)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user