Fix boolean command line parsing from int

This commit is contained in:
Wojtek Figat
2026-03-07 00:07:41 +01:00
parent befac36a4f
commit 82a02698df
2 changed files with 11 additions and 1 deletions

View File

@@ -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);

View File

@@ -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)
{