Skip to content

Commit

Permalink
feat(repl): Improve help text and banner
Browse files Browse the repository at this point in the history
Add a brief summary of the available convenience imports and helper
functions to the REPL's banner.
  • Loading branch information
Wuestengecko committed Feb 14, 2024
1 parent e69e7e2 commit dcafcb8
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions capellambse/repl.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ def _parse_args() -> dict[str, t.Any] | None:
default=None,
nargs="?",
help=(
"A model name from known_models, an AIRD file, or the path to or"
" contents of a JSON file describing the model. The following"
"A model name from known_models, an AIRD file, or the path to (or"
" contents of) a JSON file describing the model. The following"
" models are known: " + ", ".join(f"``{i}``" for i in known_models)
),
)
Expand Down Expand Up @@ -297,6 +297,21 @@ def main() -> None:
"""
)

banner += textwrap.dedent(
"""\
Convenience imports:
- `capellambse`, `inspect`, `logging`, `os`, `pathlib`
- `im` = importlib (`imm` = .metadata, `imr` = .resources)
- `etree` = lxml.etree, `pprint` = pprint.pprint
Helpful functions and context managers:
- `logtee`: CM that redirects log messages to a file
- `showxml`: Print the XML representation of a model object
- `suppress`: CM that suppresses exceptions of given type
"""
)

history_file = capellambse.dirs.user_state_path / "model_exploration.hist"
with _ReadlineHistory(history_file), suppress(BrokenPipeError):
code.interact(banner=banner, local=interactive_locals, exitmsg="")
Expand Down

0 comments on commit dcafcb8

Please sign in to comment.