replbase 0.0.12__tar.gz → 0.0.13__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: replbase
3
- Version: 0.0.12
3
+ Version: 0.0.13
4
4
  Summary: "Combination of other REPL tools into a reusable class that generates a REPL"
5
5
  License: MIT
6
6
  Author: Joseph Bochinski
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
4
4
 
5
5
  [tool.poetry]
6
6
  name = "replbase"
7
- version = "0.0.12"
7
+ version = "0.0.13"
8
8
  description = "\"Combination of other REPL tools into a reusable class that generates a REPL\""
9
9
  authors = [ "Joseph Bochinski <stirgejr@gmail.com>",]
10
10
  license = "MIT"
@@ -12,6 +12,7 @@
12
12
  """
13
13
 
14
14
  # region Imports
15
+ from __future__ import annotations
15
16
 
16
17
  import argparse
17
18
  import os
@@ -93,6 +94,8 @@ class ReplBase:
93
94
  """Command dictionary for prompt_toolkit. Keys are command names,
94
95
  values are the corresponding description/help text"""
95
96
 
97
+ parent: ReplBase = None
98
+
96
99
  def __post_init__(self) -> None:
97
100
  if isinstance(self.commands, dict):
98
101
  for cmd_name, cmd in self.commands.items():
@@ -277,6 +280,15 @@ class ReplBase:
277
280
  f"[bold green]{cmd_name}:[/bold green] [cyan]{cmd.help_txt}[/cyan]"
278
281
  )
279
282
 
283
+ def print_prompt(self) -> None:
284
+ """Prints the prompt message if defined"""
285
+
286
+ if isinstance(self.init_prompt, list):
287
+ for line in self.init_prompt:
288
+ self.print(line)
289
+ else:
290
+ self.print(self.init_prompt)
291
+
280
292
  def run(self) -> None:
281
293
  """Initiates a REPL with the provided configuration"""
282
294
 
@@ -291,11 +303,7 @@ class ReplBase:
291
303
  tempfile=self.temp_file,
292
304
  )
293
305
 
294
- if isinstance(self.init_prompt, list):
295
- for line in self.init_prompt:
296
- self.print(line)
297
- else:
298
- self.print(self.init_prompt)
306
+ self.print_prompt()
299
307
 
300
308
  while True:
301
309
  try:
@@ -304,6 +312,9 @@ class ReplBase:
304
312
  if user_input.lower() in ["help", "h"]:
305
313
  self.show_help()
306
314
  elif user_input.lower() in self.exit_keywords:
315
+ self.print(
316
+ f"[bold yellow]Exiting REPL ({self.title})...[/bold yellow]"
317
+ )
307
318
  break
308
319
  else:
309
320
  args = shlex.split(user_input)
@@ -344,7 +355,9 @@ class ReplBase:
344
355
  "[bold yellow][WARNING]: No function provided for command[/bold yellow]"
345
356
  )
346
357
  except (EOFError, KeyboardInterrupt):
347
- self.print("[bold yellow]Exiting REPL...[/bold yellow]")
358
+ self.print(
359
+ f"[bold yellow]Exiting REPL ({self.title})...[/bold yellow]"
360
+ )
348
361
  break
349
362
 
350
363
 
File without changes
File without changes