delete .hist on logout

This commit is contained in:
Diogo Sousa
2023-01-31 10:50:14 +00:00
parent 1d178ecd26
commit 309e52e80e
3 changed files with 27 additions and 0 deletions

View File

@@ -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"

View File

@@ -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.

View File

@@ -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]")