From c7aa6f367e6b779833fedee38f6c45b96f953f51 Mon Sep 17 00:00:00 2001 From: hjoaquim Date: Thu, 15 Feb 2024 13:12:18 +0000 Subject: [PATCH] move help to base class; print tables using rich table (for now); clear the choices for better autocompletion --- openbb_terminal/base_platform_controller.py | 14 ++++++++++++-- .../poc_platform_equity_controller.py | 16 +++------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/openbb_terminal/base_platform_controller.py b/openbb_terminal/base_platform_controller.py index 0dcbe162978..aa161978845 100644 --- a/openbb_terminal/base_platform_controller.py +++ b/openbb_terminal/base_platform_controller.py @@ -7,6 +7,7 @@ from functools import partial, update_wrapper from types import MethodType from typing import Dict, List, Optional +from openbb_terminal.helper_funcs import print_rich_table from openbb_terminal.core.session.current_user import get_current_user from openbb_terminal.custom_prompt_toolkit import NestedCompleter from openbb_terminal.menu import session @@ -54,7 +55,11 @@ class PlatformController(BaseController): if ns_parser := self.parse_known_args_and_warn(parser, other_args): try: obbject = translator.execute_func(parsed_args=ns_parser) - console.print(obbject.to_dataframe()) + + if hasattr(ns_parser, "chart") and ns_parser.chart: + obbject.show() + else: + print_rich_table(obbject.to_dataframe()) except Exception as e: console.print(f"[red]{e}[/]\n") @@ -91,7 +96,12 @@ class PlatformController(BaseController): """Print help.""" mt = MenuText(self._name, 80) + mt.add_raw("Menus\n\n") + for menu in self.CHOICES_MENUS: + mt.add_menu(menu) + + mt.add_raw("\nCommands\n\n") for command in self.CHOICES_COMMANDS: - mt.add_cmd(command) + mt.add_cmd(command.replace(f"{self._name}_", "")) console.print(text=mt.menu_text, menu=self._name) diff --git a/openbb_terminal/poc_platform_equity_controller.py b/openbb_terminal/poc_platform_equity_controller.py index dbf6088877c..bbbeb67ce9e 100644 --- a/openbb_terminal/poc_platform_equity_controller.py +++ b/openbb_terminal/poc_platform_equity_controller.py @@ -61,6 +61,9 @@ class PocPlatformEquityController(PlatformController): sub_menu_translators[new_name] = translator choices_commands.append(new_name) + self.CHOICES_COMMANDS.remove(translator_name) + + PlatformController.CHOICES_COMMANDS = [] PlatformController.CHOICES_COMMANDS.extend(choices_commands) self._generate_controller_call( @@ -68,16 +71,3 @@ class PocPlatformEquityController(PlatformController): name=path, translators=sub_menu_translators, ) - - def print_help(self): - """Print help.""" - mt = MenuText("poc_plat_equity/", 80) - - menus = equity.paths - - for key, value in menus.items(): - if value == "path": - continue - mt.add_menu(key) - - console.print(text=mt.menu_text, menu="POC Platform Equity")