Skip to content

Commit

Permalink
✨ [+feature] Added decoration when bootstrapped w/package flag (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbrownell authored Apr 6, 2024
2 parents 57dfcf6 + aca77e1 commit c7d372e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
24 changes: 24 additions & 0 deletions ActivateEpilog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# ----------------------------------------------------------------------
# |
# | ActivateEpilog.py
# |
# | David Brownell <[email protected]>
# | 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)))
12 changes: 12 additions & 0 deletions BootstrapEpilog.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# | Distributed under the MIT License.
# |
# ----------------------------------------------------------------------
import os
import sys

from pathlib import Path
Expand All @@ -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
]:
Expand All @@ -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:
Expand All @@ -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)
2 changes: 1 addition & 1 deletion tests/TyperEx_UnitTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def MyFunc2(
"four": (Optional[float], typer.Option(None)),
},
),
] = None,
] = [],
) -> None:
print(PostprocessDictArgument(key_value_args))

Expand Down

0 comments on commit c7d372e

Please sign in to comment.