summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhjoaquim <h.joaquim@campus.fct.unl.pt>2024-05-03 18:40:33 +0100
committerhjoaquim <h.joaquim@campus.fct.unl.pt>2024-05-03 18:40:33 +0100
commita99297843b4d117c4b4485f71ff0b0753edcffe1 (patch)
tree2057e7d127f153faccc76cfbfa0fdcfbe6bea00a
parent510db81c892e8fbf67d21993777e0e16f6feba2d (diff)
new settings to control the obbject registry
-rw-r--r--cli/openbb_cli/assets/i18n/en.yml2
-rw-r--r--cli/openbb_cli/controllers/feature_flags_controller.py38
-rw-r--r--cli/openbb_cli/models/settings.py6
3 files changed, 44 insertions, 2 deletions
diff --git a/cli/openbb_cli/assets/i18n/en.yml b/cli/openbb_cli/assets/i18n/en.yml
index a8d06e45b88..05a772b7320 100644
--- a/cli/openbb_cli/assets/i18n/en.yml
+++ b/cli/openbb_cli/assets/i18n/en.yml
@@ -34,3 +34,5 @@ en:
settings/language: translation language
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
diff --git a/cli/openbb_cli/controllers/feature_flags_controller.py b/cli/openbb_cli/controllers/feature_flags_controller.py
index 41d2c520f54..e0210680b69 100644
--- a/cli/openbb_cli/controllers/feature_flags_controller.py
+++ b/cli/openbb_cli/controllers/feature_flags_controller.py
@@ -39,6 +39,8 @@ class FeatureFlagsController(BaseController):
"language",
"n_rows",
"n_cols",
+ "obbject_registry_msg",
+ "obbject_registry_res",
]
PATH = "/settings/"
CHOICES_GENERATION = True
@@ -65,6 +67,7 @@ class FeatureFlagsController(BaseController):
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_raw("\n")
mt.add_info("_settings_")
mt.add_raw("\n")
@@ -74,6 +77,7 @@ class FeatureFlagsController(BaseController):
mt.add_cmd("language")
mt.add_cmd("n_rows")
mt.add_cmd("n_cols")
+ mt.add_cmd("obbject_res")
session.console.print(text=mt.menu_text, menu="Feature Flags")
@@ -131,6 +135,13 @@ class FeatureFlagsController(BaseController):
session.console.print("Will take effect when running CLI again.")
session.settings.set_item("TOOLBAR_HINT", not session.settings.TOOLBAR_HINT)
+ def call_obbject_msg(self, _):
+ """Process obbject_msg command."""
+ session.settings.set_item(
+ "SHOW_MSG_OBBJECT_REGISTRY",
+ not session.settings.SHOW_MSG_OBBJECT_REGISTRY,
+ )
+
def call_console_style(self, other_args: List[str]) -> None:
"""Process cosole_style command."""
parser = argparse.ArgumentParser(
@@ -287,3 +298,30 @@ class FeatureFlagsController(BaseController):
session.console.print(
f"Current number of columns: {session.settings.ALLOWED_NUMBER_OF_COLUMNS}"
)
+
+ def call_obbject_res(self, other_args: List[str]):
+ """Process obbject_res command."""
+ parser = argparse.ArgumentParser(
+ formatter_class=argparse.ArgumentDefaultsHelpFormatter,
+ prog="obbject_res",
+ description="Maximum allowed number of results to keep in the OBBject Registry.",
+ add_help=False,
+ )
+ parser.add_argument(
+ "-n",
+ "--number",
+ dest="number",
+ action="store",
+ required=False,
+ type=int,
+ )
+ ns_parser = self.parse_simple_args(parser, other_args)
+
+ if ns_parser and ns_parser.number:
+ session.settings.set_item("N_TO_KEEP_OBBJECT_REGISTRY", ns_parser.columns)
+
+ elif not other_args:
+ session.console.print(
+ f"Current maximum allowed number of results to keep in the OBBject registry:"
+ f" {session.settings.N_TO_KEEP_OBBJECT_REGISTRY}"
+ )
diff --git a/cli/openbb_cli/models/settings.py b/cli/openbb_cli/models/settings.py
index f83bca01ab3..c30f6ff9952 100644
--- a/cli/openbb_cli/models/settings.py
+++ b/cli/openbb_cli/models/settings.py
@@ -33,19 +33,21 @@ class Settings(BaseModel):
REMEMBER_CONTEXTS: bool = True
ENABLE_RICH_PANEL: bool = True
TOOLBAR_HINT: bool = True
+ SHOW_MSG_OBBJECT_REGISTRY: bool = False
# GENERAL
TIMEZONE: str = "America/New_York"
FLAIR: str = ":openbb"
USE_LANGUAGE: str = "en"
PREVIOUS_USE: bool = False
+ N_TO_KEEP_OBBJECT_REGISTRY: int = 10
# STYLE
RICH_STYLE: str = "dark"
# OUTPUT
- ALLOWED_NUMBER_OF_ROWS: int = 366
- ALLOWED_NUMBER_OF_COLUMNS: int = 15
+ ALLOWED_NUMBER_OF_ROWS: int = 20
+ ALLOWED_NUMBER_OF_COLUMNS: int = 5
# OPENBB
HUB_URL: str = "https://my.openbb.co"