mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-29 05:21:48 +00:00
delete .hist on logout
This commit is contained in:
@@ -35,6 +35,7 @@ REPOSITORY_ENV_FILE = REPOSITORY_DIRECTORY / ".env"
|
||||
PACKAGE_ENV_FILE = PACKAGE_DIRECTORY / ".env"
|
||||
|
||||
SETTINGS_DIRECTORY = HOME_DIRECTORY / ".openbb_terminal"
|
||||
HIST_FILE_PATH = os.path.join(os.path.expanduser("~"), ".openbb_terminal.his")
|
||||
USER_ENV_FILE = SETTINGS_DIRECTORY / ".env"
|
||||
USER_DATA_DIRECTORY = get_user_data_directory()
|
||||
USER_EXPORTS_DIRECTORY = USER_DATA_DIRECTORY / "exports"
|
||||
|
||||
@@ -3,6 +3,7 @@ from pathlib import Path
|
||||
import json
|
||||
from typing import Optional
|
||||
from openbb_terminal.core.config.paths import (
|
||||
HIST_FILE_PATH,
|
||||
SETTINGS_DIRECTORY,
|
||||
USER_ROUTINES_DIRECTORY,
|
||||
)
|
||||
@@ -79,6 +80,30 @@ def remove_session_file(file_path: Path = SESSION_FILE_PATH) -> bool:
|
||||
return False
|
||||
|
||||
|
||||
def remove_cli_history_file(file_path: Path = Path(HIST_FILE_PATH)) -> bool:
|
||||
"""Remove the cli history file.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
file_path : Path
|
||||
The file path.
|
||||
|
||||
Returns
|
||||
-------
|
||||
bool
|
||||
The status of the removal.
|
||||
"""
|
||||
|
||||
try:
|
||||
if os.path.isfile(file_path):
|
||||
os.remove(file_path)
|
||||
return True
|
||||
return True
|
||||
except Exception:
|
||||
console.print("[red]\nFailed to remove terminal history file.[/red]")
|
||||
return False
|
||||
|
||||
|
||||
def apply_configs(configs: dict):
|
||||
"""Apply configurations.
|
||||
|
||||
|
||||
@@ -86,5 +86,6 @@ def logout(cls: bool = False):
|
||||
|
||||
Hub.delete_session()
|
||||
Local.remove_session_file()
|
||||
Local.remove_cli_history_file()
|
||||
plt.close("all")
|
||||
console.print("[green]\nLogout successful.[/green]")
|
||||
|
||||
Reference in New Issue
Block a user