diff options
author | Danglewood <85772166+deeleeramone@users.noreply.github.com> | 2024-05-10 18:42:16 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-10 18:42:16 -0700 |
commit | 0092af7a832003f9d44517615696c62449b5ba0a (patch) | |
tree | 236b9fd016fa23aaaec2619013505a9aae5fca0f | |
parent | 43836d7f185f2a101ef22cfbb21e92fdbacd7301 (diff) | |
parent | ac745adb05e732a94e7f19d92a72b805902c49bf (diff) |
Merge branch 'develop' into bugfix/econ-calendar
59 files changed, 5307 insertions, 4164 deletions
diff --git a/cli/openbb_cli/assets/i18n/en.yml b/cli/openbb_cli/assets/i18n/en.yml deleted file mode 100644 index 2e19ee4ce39..00000000000 --- a/cli/openbb_cli/assets/i18n/en.yml +++ /dev/null @@ -1,36 +0,0 @@ -en: - intro: introduction on the OpenBB Platform CLI - support: pre-populate a support ticket for our team to evaluate - survey: fill in our 2-minute survey so we better understand how we can improve the CLI - settings: enable and disable feature flags, preferences and settings - _scripts_: Record and execute your own .openbb routine scripts - record: start recording current session - stop: stop session recording and convert to .openbb routine - exe: execute .openbb routine scripts (use exe --example for an example) - _configure_: Configure your own CLI - _main_menu_: Main menu - settings/_feature_flags_: Feature flags - settings/_preferences_: Preferences - settings/retryload: retry misspelled commands with load first - settings/interactive: open dataframes in interactive window - settings/cls: clear console after each command - settings/color: use coloring features - settings/promptkit: enable prompt toolkit (autocomplete and history) - settings/thoughts: thoughts of the day - settings/reporthtml: open report as HTML otherwise notebook - settings/exithelp: automatically print help when quitting menu - settings/rich: colorful rich CLI - settings/richpanel: colorful rich CLI panel - settings/watermark: watermark in figures - settings/cmdloc: command location displayed in figures - settings/overwrite: whether to overwrite Excel files if they already exists - settings/version: whether to show the version in the bottom right corner - settings/tbhint: displays usage hints in the bottom toolbar - settings/console_style: apply a custom rich style to the CLI - settings/flair: choose flair icon - settings/timezone: pick timezone - settings/n_rows: number of rows to show on non interactive tables - settings/n_cols: number of columns to show on non interactive tables - settings/obbject_msg: show obbject registry message after a new result is added - settings/obbject_res: define the maximum number of obbjects allowed in the registry - settings/obbject_display: define the maximum number of cached results to display on the help menu diff --git a/cli/openbb_cli/config/constants.py b/cli/openbb_cli/config/constants.py index 08aa50e107a..adac9bfd6f2 100644 --- a/cli/openbb_cli/config/constants.py +++ b/cli/openbb_cli/config/constants.py @@ -11,7 +11,6 @@ ASSETS_DIRECTORY = SRC_DIRECTORY / "assets" STYLES_DIRECTORY = ASSETS_DIRECTORY / "styles" ENV_FILE_SETTINGS = SETTINGS_DIRECTORY / ".cli.env" HIST_FILE_PROMPT = SETTINGS_DIRECTORY / ".cli.his" -I18N_FILE = ASSETS_DIRECTORY / "i18n" DEFAULT_ROUTINES_URL = "https://openbb-cms.directus.app/items/Routines" diff --git a/cli/openbb_cli/config/menu_text.py b/cli/openbb_cli/config/menu_text.py index e4b4e1bf8c2..06c7023ef1f 100644 --- a/cli/openbb_cli/config/menu_text.py +++ b/cli/openbb_cli/config/menu_text.py @@ -4,7 +4,6 @@ __docformat__ = "numpy" from typing import Dict, List -import i18n from openbb import obb # https://rich.readthedocs.io/en/stable/appendix/colors.html#appendix-colors @@ -92,10 +91,8 @@ class MenuText: self, name: str, description: str, trim: bool = True ) -> str: """Truncate command description length if it is too long.""" - if not description: - description = i18n.t(self.menu_path + name) - if description == self.menu_path + name: - description = "" + if not description or description == f"{self.menu_path}{name}": + description = "" return ( description[: self.CMD_DESCRIPTION_LENGTH - 3] + "..." if len(description) > self.CMD_DESCRIPTION_LENGTH and trim @@ -122,23 +119,9 @@ class MenuText: else: self.menu_text += text - def add_custom(self, name: str): - """Append custom text (after translation).""" - self.menu_text += f"{i18n.t(self.menu_path + name)}" - def add_info(self, text: str): """Append information text (after translation).""" - self.menu_text += f"[info]{i18n.t(self.menu_path + text)}:[/info]\n" - - def add_param(self, name: str, value: str, col_align: int = 0): - """Append parameter (after translation).""" - parameter_translated = i18n.t(self.menu_path + name) - space = ( - (col_align - len(parameter_translated)) * " " - if col_align > len(parameter_translated) - else "" - ) - self.menu_text += f"[param]{parameter_translated}{space}:[/param] {value}\n" + self.menu_text += f"[info]{text}:[/info]\n" def add_cmd(self, name: str, description: str = "", disable: bool = False): """Append command text (after translation).""" @@ -174,10 +157,8 @@ class MenuText: """Append menu text (after translation).""" spacing = (self.CMD_NAME_LENGTH - len(name) + self.SECTION_SPACING) * " " - if not description: - description = i18n.t(self.menu_path + name) - if description == self.menu_path + name: - description = "" + if not description or description == f"{self.menu_path}{name}": + description = "" if len(description) > self.CMD_DESCRIPTION_LENGTH: description = description[: self.CMD_DESCRIPTION_LENGTH - 3] + "..." @@ -186,9 +167,12 @@ class MenuText: tag = "unvl" if disable else "menu" self.menu_text += f"[{tag}]> {menu}[/{tag}]\n" - def add_setting(self, name: str, status: bool = True): + def add_setting(self, name: str, status: bool = True, description: str = ""): """Append menu text (after translation).""" spacing = (self.CMD_NAME_LENGTH - len(name) + self.SECTION_SPACING) * " " indentation = self.SECTION_SPACING * " " color = "green" if status else "red" - self.menu_text += f"[{color}]{indentation}{name}{spacing}{i18n.t(self.menu_path + name)}[/{color}]\n" + + self.menu_text += ( + f"[{color}]{indentation}{name}{spacing}{description}[/{color}]\n" + ) diff --git a/cli/openbb_cli/config/setup.py b/cli/openbb_cli/config/setup.py index c507e5645a7..4d3eece690b 100644 --- a/cli/openbb_cli/config/setup.py +++ b/cli/openbb_cli/config/setup.py @@ -4,9 +4,7 @@ import copy from pathlib import Path from typing import TYPE_CHECKING, List, Optional, TypeVar -import i18n - -from openbb_cli.config.constants import ENV_FILE_SETTINGS, I18N_FILE, SETTINGS_DIRECTORY +from openbb_cli.config.constants import ENV_FILE_SETTINGS, SETTINGS_DIRECTORY if TYPE_CHECKING: from openbb_charting.core.openbb_figure import OpenBBFigure @@ -69,13 +67,6 @@ def set_current_figure(fig: Optional[OpenBBFigureT] = None): current_figure = fig -def setup_i18n(i18n_path: Path = I18N_FILE, lang: str = "en"): - """Select the CLI translation language.""" - i18n.load_path.append(i18n_path) - i18n.set("locale", lang) - i18n.set("filename_format", "{locale}.{format}") - - def bootstrap(): """Setup pre-launch configurations for the CLI.""" SETTINGS_DIRECTORY.mkdir(parents=True, exist_ok=True) diff --git a/cli/openbb_cli/controllers/cli_controller.py b/cli/openbb_cli/controllers/cli_controller.py index e44237ba82d..aec72410a84 100644 --- a/cli/openbb_cli/controllers/cli_controller.py +++ b/cli/openbb_cli/controllers/cli_controller.py @@ -220,13 +220,21 @@ class CLIController(BaseController): def print_help(self): """Print help.""" mt = MenuText("") - mt.add_info("_configure_") - mt.add_menu("settings") + mt.add_info("Configure your own CLI") + mt.add_menu( + "settings", + description="enable and disable feature flags, preferences and settings", + ) mt.add_raw("\n") - mt.add_info("_scripts_") - mt.add_cmd("record") - mt.add_cmd("stop") - mt.add_cmd("exe") + mt.add_info("Record and execute your own .openbb routine scripts") + mt.add_cmd("record", description="start recording current session") + mt.add_cmd( + "stop", description="stop session recording and convert to .openbb routine" + ) + mt.add_cmd( + "exe", + description="execute .openbb routine scripts (use exe --example for an example)", + ) mt.add_raw("\n") mt.add_info("Retrieve data from different asset classes and providers") diff --git a/cli/openbb_cli/controllers/settings_controller.py b/cli/openbb_cli/controllers/settings_controller.py index 9f87d4cc677..f01742f6cb2 100644 --- a/cli/openbb_cli/controllers/settings_controller.py +++ b/cli/openbb_cli/controllers/settings_controller.py @@ -19,7 +19,6 @@ class SettingsController(BaseController): """Settings Controller class.""" CHOICES_COMMANDS: List[str] = [ - "retryload", "tab", "interactive", "cls", @@ -56,26 +55,76 @@ class SettingsController(BaseController): settings = session.settings mt = MenuText("settings/") - mt.add_info("_feature_flags_") - mt.add_setting("interactive", settings.USE_INTERACTIVE_DF) - mt.add_setting("cls", settings.USE_CLEAR_AFTER_CMD) - mt.add_setting("promptkit", settings.USE_PROMPT_TOOLKIT) - mt.add_setting("exithelp", settings.ENABLE_EXIT_AUTO_HELP) - mt.add_setting("rcontext", settings.REMEMBER_CONTEXTS) - mt.add_setting("richpanel", settings.ENABLE_RICH_PANEL) - mt.add_setting("tbhint", settings.TOOLBAR_HINT) - mt.add_setting("overwrite", settings.FILE_OVERWRITE) - mt.add_setting("version", settings.SHOW_VERSION) - mt.add_setting("obbject_msg", settings.SHOW_MSG_OBBJECT_REGISTRY) + mt.add_info("Feature flags") + mt.add_setting( + "interactive", + settings.USE_INTERACTIVE_DF, + description="open dataframes in interactive window", + ) + mt.add_setting( + "cls", + settings.USE_CLEAR_AFTER_CMD, + description="clear console after each command", + ) + mt.add_setting( + "promptkit", + settings.USE_PROMPT_TOOLKIT, + description="enable prompt toolkit (autocomplete and history)", + ) + mt.add_setting( + "exithelp", + settings.ENABLE_EXIT_AUTO_HELP, + description="automatically print help when quitting menu", + ) + mt.add_setting( + "rcontext", + settings.REMEMBER_CONTEXTS, + description="remember contexts between menus", + ) + mt.add_setting( + "richpanel", + settings.ENABLE_RICH_PANEL, + description="colorful rich CLI panel", + ) + mt.add_setting( + "tbhint", + settings.TOOLBAR_HINT, + description="displays usage hints in the bottom toolbar", + ) + mt.add_setting( + "overwrite", + settings.FILE_OVERWRITE, + description="whether to overwrite Excel files if they already exists", + ) + mt.add_setting( + "version", + settings.SHOW_VERSION, + description="whether to show the version in the bottom right corner", + ) + mt.add_setting( + "obbject_msg", + settings.SHOW_MSG_OBBJECT_REGISTRY, + description="show obbject registry message after a new result is added", + ) mt.add_raw("\n") - mt.add_info("_preferences_") - mt.add_cmd("console_style") - mt.add_cmd("flair") - mt.add_cmd("timezone") - mt.add_cmd("n_rows") - mt.add_cmd("n_cols") - mt.add_cmd("obbject_res") - mt.add_cmd("obbject_display") + mt.add_info("Preferences") + mt.add_cmd("console_style", description="apply a custom rich style to the CLI") + mt.add_cmd("flair", description="choose flair icon") + mt.add_cmd("timezone", description="pick timezone") + mt.add_cmd( + "n_rows", description="number of rows to show on non interactive tables" + ) + mt.add_cmd( + "n_cols", description="number of columns to show on non interactive tables" + ) |