29 lines
574 B
Python
Raw Normal View History

2024-02-19 19:53:08 +08:00
from contextlib import AbstractContextManager
2024-01-12 11:12:12 +08:00
class Step(AbstractContextManager):
"""
Show a running step in the TUI.
ChatMark syntax:
```Step
# Something is running...
some details...
```
Usage:
with Step("Something is running..."):
print("some details...")
"""
def __init__(self, title: str):
self.title = title
def __enter__(self):
print(f"\n```Step\n# {self.title}", flush=True)
def __exit__(self, exc_type, exc_val, exc_tb):
# close the step
2024-02-19 19:53:08 +08:00
print("\n```", flush=True)