mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-11 20:01:16 +00:00
config to set number of cached results to display
This commit is contained in:
1
cli/openbb_cli/assets/i18n/en.yml
vendored
1
cli/openbb_cli/assets/i18n/en.yml
vendored
@@ -36,3 +36,4 @@ en:
|
||||
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
|
||||
@@ -323,7 +323,9 @@ class PlatformController(BaseController):
|
||||
|
||||
if session.obbject_registry.obbjects:
|
||||
mt.add_section("Cached Results:\n", leading_new_line=True)
|
||||
for key, value in session.obbject_registry.all.items():
|
||||
for key, value in list(session.obbject_registry.all.items())[
|
||||
: session.settings.N_TO_DISPLAY_OBBJECT_REGISTRY
|
||||
]:
|
||||
mt.add_raw(f"\tOBB{key}: {value['command']}\n")
|
||||
|
||||
session.console.print(text=mt.menu_text, menu=self.PATH)
|
||||
|
||||
@@ -287,7 +287,9 @@ class CLIController(BaseController):
|
||||
mt.add_cmd("results")
|
||||
if session.obbject_registry.obbjects:
|
||||
mt.add_section("Cached Results:\n", leading_new_line=True)
|
||||
for key, value in session.obbject_registry.all.items():
|
||||
for key, value in list(session.obbject_registry.all.items())[
|
||||
: session.settings.N_TO_DISPLAY_OBBJECT_REGISTRY
|
||||
]:
|
||||
mt.add_raw(f"\tOBB{key}: {value['command']}\n")
|
||||
|
||||
session.console.print(text=mt.menu_text, menu="Home")
|
||||
|
||||
@@ -41,6 +41,7 @@ class SettingsController(BaseController):
|
||||
"n_cols",
|
||||
"obbject_msg",
|
||||
"obbject_res",
|
||||
"obbject_display",
|
||||
]
|
||||
PATH = "/settings/"
|
||||
CHOICES_GENERATION = True
|
||||
@@ -76,6 +77,7 @@ class SettingsController(BaseController):
|
||||
mt.add_cmd("n_rows")
|
||||
mt.add_cmd("n_cols")
|
||||
mt.add_cmd("obbject_res")
|
||||
mt.add_cmd("obbject_display")
|
||||
|
||||
session.console.print(text=mt.menu_text, menu="Settings")
|
||||
|
||||
@@ -323,3 +325,30 @@ class SettingsController(BaseController):
|
||||
f"Current maximum allowed number of results to keep in the OBBject registry:"
|
||||
f" {session.settings.N_TO_KEEP_OBBJECT_REGISTRY}"
|
||||
)
|
||||
|
||||
def call_obbject_display(self, other_args: List[str]):
|
||||
"""Process obbject_display command."""
|
||||
parser = argparse.ArgumentParser(
|
||||
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
|
||||
prog="obbject_display",
|
||||
description="Number of results to display from 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_DISPLAY_OBBJECT_REGISTRY", ns_parser.number)
|
||||
|
||||
elif not other_args:
|
||||
session.console.print(
|
||||
f"Current number of results to display from the OBBject registry:"
|
||||
f" {session.settings.N_TO_DISPLAY_OBBJECT_REGISTRY}"
|
||||
)
|
||||
|
||||
@@ -37,6 +37,7 @@ class Settings(BaseModel):
|
||||
USE_LANGUAGE: str = "en"
|
||||
PREVIOUS_USE: bool = False
|
||||
N_TO_KEEP_OBBJECT_REGISTRY: int = 10
|
||||
N_TO_DISPLAY_OBBJECT_REGISTRY: int = 5
|
||||
|
||||
# STYLE
|
||||
RICH_STYLE: str = "dark"
|
||||
|
||||
Reference in New Issue
Block a user