From aca77e116f0000d86689ffdaaee4461274d88c21 Mon Sep 17 00:00:00 2001 From: David Brownell Date: Sat, 6 Apr 2024 19:33:39 -0400 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20[+feature]=20Added=20decoration=20w?= =?UTF-8?q?hen=20bootstrapped=20w/package=20flag?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ActivateEpilog.py | 24 ++++++++++++++++++++++++ BootstrapEpilog.py | 12 ++++++++++++ tests/TyperEx_UnitTest.py | 2 +- 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 ActivateEpilog.py diff --git a/ActivateEpilog.py b/ActivateEpilog.py new file mode 100644 index 0000000..7c86868 --- /dev/null +++ b/ActivateEpilog.py @@ -0,0 +1,24 @@ +# ---------------------------------------------------------------------- +# | +# | ActivateEpilog.py +# | +# | David Brownell +# | 2024-04-06 19:39:24 +# | +# ---------------------------------------------------------------------- +# | +# | Copyright David Brownell 2024 +# | Distributed under the MIT License. +# | +# ---------------------------------------------------------------------- +import json +import os +import sys + +from pathlib import Path + +with (Path(os.environ["PYTHON_BOOTSTRAPPER_GENERATED_DIR"]) / "bootstrap_flags.json").open() as f: + flags = json.load(f) + +if flags: + sys.stdout.write("\nBootstrapped with {}.\n".format(", ".join(f"'{flag}'" for flag in flags))) diff --git a/BootstrapEpilog.py b/BootstrapEpilog.py index 739bdd9..f5d2879 100644 --- a/BootstrapEpilog.py +++ b/BootstrapEpilog.py @@ -11,6 +11,7 @@ # | Distributed under the MIT License. # | # ---------------------------------------------------------------------- +import os import sys from pathlib import Path @@ -28,6 +29,8 @@ is_package = False no_cache = False +display_flags: list[str] = [] + for arg in sys.argv[ 2: # First arg is the script name, second arg is the name of the shell script to write to ]: @@ -39,6 +42,7 @@ is_verbose = True elif arg == "--package": is_package = True + display_flags.append("package") elif arg == "--no-cache": no_cache = True else: @@ -65,4 +69,12 @@ stream, ) + with dm.Nested("Saving bootstrap flags..."): + with ( + Path(__file__).parent + / os.environ["PYTHON_BOOTSTRAPPER_GENERATED_DIR"] + / "bootstrap_flags.json" + ).open("w") as f: + f.write("[{}]".format(", ".join(f'"{flag}"' for flag in display_flags))) + sys.exit(dm.result) diff --git a/tests/TyperEx_UnitTest.py b/tests/TyperEx_UnitTest.py index 66d7239..df1cc41 100644 --- a/tests/TyperEx_UnitTest.py +++ b/tests/TyperEx_UnitTest.py @@ -270,7 +270,7 @@ def MyFunc2( "four": (Optional[float], typer.Option(None)), }, ), - ] = None, + ] = [], ) -> None: print(PostprocessDictArgument(key_value_args))