|
29 | 29 | convert_from_rest, |
30 | 30 | get_library_doc, |
31 | 31 | ) |
| 32 | +from robotcode.robot.utils import get_robot_version_str |
32 | 33 | from robotcode.robot.utils.markdownformatter import MarkDownFormatter |
33 | 34 |
|
| 35 | +from .__version__ import __version__ |
34 | 36 | from ._indent import compute_indent |
35 | 37 | from ._keyword_lookup import _LIB_KEYWORDS_ATTR, lookup_keyword_doc, lookup_library_doc |
36 | 38 | from ._session_export import render_robot_file |
@@ -341,6 +343,28 @@ def show_doc(self, title: str, markdown: str) -> None: |
341 | 343 | if self.app is not None: |
342 | 344 | self.app.echo_via_pager(body, color=False) |
343 | 345 |
|
| 346 | + def show_banner(self) -> None: |
| 347 | + """Print a Python-REPL-style banner before the first prompt. |
| 348 | +
|
| 349 | + Skipped when stdin isn't a TTY (input piped/redirected) or |
| 350 | + when running non-interactively from ``--files`` without |
| 351 | + ``--inspect`` — neither case ever reaches an interactive prompt. |
| 352 | + """ |
| 353 | + if self.app is None or not sys.stdin.isatty(): |
| 354 | + return |
| 355 | + if self.files and not self.inspect: |
| 356 | + return |
| 357 | + |
| 358 | + py = f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}" |
| 359 | + rf = get_robot_version_str() |
| 360 | + header = f"RobotCode REPL {__version__} (Robot Framework {rf}, Python {py} on {sys.platform})" |
| 361 | + self.app.echo(click.style(header, bold=True)) |
| 362 | + self.app.echo('Type ".help" for commands, ".exit" to quit.') |
| 363 | + |
| 364 | + def run(self) -> Any: |
| 365 | + self.show_banner() |
| 366 | + return super().run() |
| 367 | + |
344 | 368 | # ------------------------------------------------------------------ |
345 | 369 | # Robot integration |
346 | 370 | # ------------------------------------------------------------------ |
|
0 commit comments