pull command output

This commit is contained in:
Diogo Sousa
2023-01-27 17:56:09 +00:00
parent cc3dd782b1
commit af46d2eacf
4 changed files with 38 additions and 7 deletions

View File

@@ -13,7 +13,9 @@ from openbb_terminal.core.config.paths import USER_ROUTINES_DIRECTORY
from openbb_terminal import feature_flags as obbff
from openbb_terminal.menu import session
from openbb_terminal.session import hub_model as Hub
from openbb_terminal.session import local_model as Local
from openbb_terminal.session.user import User
from openbb_terminal.account.account_model import show_diff
# from openbb_terminal.session.user import User
@@ -128,14 +130,16 @@ class AccountController(BaseController):
if ns_parser:
response = Hub.fetch_user_configs(User.get_session())
if response:
console.print("Remote data:", style="info")
console.print(json.loads(response.content))
configs = json.loads(response.content)
show_diff(configs=configs)
i = console.input(
"\nDo you want to overwrite your local configurations "
"with the remote? (y/n): "
"with the above? (y/n): "
)
if i.lower() in ["y", "yes"]:
console.print("[green]\nApplied remote configs.[/green]")
Local.apply_configs(configs=configs)
console.print("\nDone.", style="info")
else:
console.print("\nAborted.", style="info")

View File

@@ -0,0 +1,27 @@
from openbb_terminal.rich_config import console
def show_diff(configs: dict):
"""Show the diff between the local and remote configs.
Parameters
----------
configs : dict
The configs.
"""
if configs:
settings = configs.get("features_settings", {})
keys = configs.get("features_keys", {})
if settings:
console.print("Settings:", style="info")
for k, v in sorted(settings.items()):
console.print(f"[menu]{k}[/menu]: {v}")
if keys:
if settings:
console.print("")
console.print("Keys:", style="info")
for k, v in sorted(keys.items()):
console.print(f"[menu]{k}[/menu]: {v}")

View File

@@ -19,8 +19,8 @@ en:
_main_menu_: Main menu
account/_info_: Cloud storage of keys, settings and feature flags
account/sync: Turns the cloud synchronization on/off
account/pull: Pull from cloud
account/clear: Clear data from remote cloud
account/pull: Pull data from cloud
account/clear: Clear data from cloud
account/_routines_: Routines
account/upload: Upload routine
account/download: Download routine

View File

@@ -87,7 +87,7 @@ def apply_configs(configs: dict):
configs : dict
The configurations.
"""
console.print(configs, style="red")
# console.print(configs, style="red")
if configs:
settings = configs.get("features_settings", {})