From 4bd794dbd16687eb755c8ed17ea1b654e2511a2a Mon Sep 17 00:00:00 2001 From: Alex Pyrgiotis Date: Wed, 4 Dec 2024 13:30:56 +0200 Subject: [PATCH] Allow passing true/false to --use-cache build arg --- install/common/build-image.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/install/common/build-image.py b/install/common/build-image.py index 3e2ab71..6d99877 100644 --- a/install/common/build-image.py +++ b/install/common/build-image.py @@ -18,6 +18,17 @@ elif platform.system() == "Linux": ARCH = platform.machine() +def str2bool(v): + if isinstance(v, bool): + return v + if v.lower() in ("yes", "true", "t", "y", "1"): + return True + elif v.lower() in ("no", "false", "f", "n", "0"): + return False + else: + raise argparse.ArgumentTypeError("Boolean value expected.") + + def main(): parser = argparse.ArgumentParser() parser.add_argument( @@ -40,7 +51,10 @@ def main(): ) parser.add_argument( "--use-cache", - action="store_true", + type=str2bool, + nargs="?", + default=False, + const=True, help="Use the builder's cache to speed up the builds (not suitable for release builds)", ) args = parser.parse_args()