From 80a4796405cb95522689ce10a3849a5e1aca91ef Mon Sep 17 00:00:00 2001 From: devwolff <62347426+devwolff@users.noreply.github.com> Date: Tue, 11 Jan 2022 04:34:27 +1000 Subject: [PATCH] print_help when jump back to previous menu (#1168) * print_help when jump back to previous menu * help when quitting * default flag to False Co-authored-by: theorish Co-authored-by: DidierRLopes --- gamestonk_terminal/feature_flags.py | 3 +++ gamestonk_terminal/parent_classes.py | 3 +++ terminal.py | 3 +++ 3 files changed, 9 insertions(+) diff --git a/gamestonk_terminal/feature_flags.py b/gamestonk_terminal/feature_flags.py index 598d2e650a9..68573d346b8 100644 --- a/gamestonk_terminal/feature_flags.py +++ b/gamestonk_terminal/feature_flags.py @@ -42,3 +42,6 @@ ENABLE_QUICK_EXIT = strtobool(os.getenv("GTFF_ENABLE_QUICK_EXIT", "False")) # Open report as HTML, otherwise notebook OPEN_REPORT_AS_HTML = strtobool(os.getenv("GTFF_OPEN_REPORT_AS_HTML", "True")) + +# Enable auto print_help when exiting menus +ENABLE_EXIT_AUTO_HELP = strtobool(os.getenv("GTFF_ENABLE_EXIT_AUTO_HELP", "False")) diff --git a/gamestonk_terminal/parent_classes.py b/gamestonk_terminal/parent_classes.py index ac228496d77..f47f6a746f0 100644 --- a/gamestonk_terminal/parent_classes.py +++ b/gamestonk_terminal/parent_classes.py @@ -185,6 +185,9 @@ class BaseController(metaclass=ABCMeta): if len(self.queue) > 1: return self.queue[1:] + + if gtff.ENABLE_EXIT_AUTO_HELP: + return ["help"] return [] # Consume 1 element from the queue diff --git a/terminal.py b/terminal.py index ecb2e7c37da..4b12273f5a9 100644 --- a/terminal.py +++ b/terminal.py @@ -230,6 +230,9 @@ def terminal(jobs_cmds: List[str] = None): print_goodbye() break + if gtff.ENABLE_EXIT_AUTO_HELP and len(t_controller.queue) > 1: + t_controller.queue = t_controller.queue[1:] + # Consume 1 element from the queue an_input = t_controller.queue[0] t_controller.queue = t_controller.queue[1:]