shell.py
1 from typing import Any 2 3 import sentry_sdk 4 5 from .command import command 6 from ..context import LoginContext, MainContext, DeviceContext 7 8 9 @command("clear", [LoginContext, MainContext, DeviceContext]) 10 def handle_main_clear(*_: Any) -> None: 11 """ 12 Clear the console 13 """ 14 15 print(end="\033c") 16 17 18 @command("history", [MainContext, DeviceContext]) 19 def handle_main_history(context: MainContext, _: Any) -> None: 20 """ 21 Show the history of commands entered in this session 22 """ 23 24 for line in context.history: 25 print(line) 26 27 28 @command("feedback", [LoginContext, MainContext, DeviceContext]) 29 def handle_feedback(context: LoginContext, _: Any) -> None: 30 """ 31 Send feedback to the developer 32 """ 33 34 print("Please type your feedback about PyCrypCli below. When you are done press Ctrl+C") 35 feedback = ["User Feedback"] 36 if isinstance(context, MainContext) and context.username: 37 feedback[0] += " from " + context.username 38 while True: 39 try: 40 feedback.append(input("> ")) 41 except (KeyboardInterrupt, EOFError): 42 break 43 print() 44 print("=" * 30) 45 print("\n".join(feedback)) 46 print("=" * 30) 47 if context.ask("Do you want to send this feedback to the developer? [yes|no] ", ["yes", "no"]) == "yes": 48 sentry_sdk.capture_message("\n".join(feedback))