From 82a02698df196e44fcae85829a02d4a85c429b7a Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Sat, 7 Mar 2026 00:07:41 +0100 Subject: [PATCH] Fix boolean command line parsing from int --- Source/Tools/Flax.Build.Tests/TestCommandLine.cs | 6 ++++++ Source/Tools/Flax.Build/CommandLine.cs | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Source/Tools/Flax.Build.Tests/TestCommandLine.cs b/Source/Tools/Flax.Build.Tests/TestCommandLine.cs index 11d013a8c..0feb788e6 100644 --- a/Source/Tools/Flax.Build.Tests/TestCommandLine.cs +++ b/Source/Tools/Flax.Build.Tests/TestCommandLine.cs @@ -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); diff --git a/Source/Tools/Flax.Build/CommandLine.cs b/Source/Tools/Flax.Build/CommandLine.cs index 10b26d613..226ba9913 100644 --- a/Source/Tools/Flax.Build/CommandLine.cs +++ b/Source/Tools/Flax.Build/CommandLine.cs @@ -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) {