From cc15a770daa013f61cf8cf42218d877513ad64be Mon Sep 17 00:00:00 2001 From: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Date: Tue, 30 Apr 2024 13:42:31 +0100 Subject: [PATCH] [Feature] - Rename terminal folder (#6349) * rename terminal folder * docstring * Rename to openbb_cli * rename constant * rename .his file * pyproject.toml * Update pre-commit and remove docker-build.yml --- .github/workflows/docker-build.yml | 48 ---------- .gitignore | 6 +- .pre-commit-config.yaml | 1 - {openbb_terminal => cli}/CONTRIBUTING.md | 0 {openbb_terminal => cli}/README.md | 0 .../openbb_cli}/__init__.py | 0 .../argparse_translator/__init__.py | 0 .../argparse_class_processor.py | 2 +- .../argparse_translator.py | 0 .../argparse_translator/obbject_registry.py | 0 .../openbb_cli}/assets/i18n/en.yml | 2 +- .../assets/routines/routine_example.openbb | 0 .../assets/styles/default/Consolas.ttf | Bin .../assets/styles/default/dark.mpfstyle.json | 0 .../assets/styles/default/dark.mplrc.json | 0 .../assets/styles/default/dark.mplstyle | 0 .../assets/styles/default/dark.pltstyle.json | 0 .../assets/styles/default/dark.richstyle.json | 0 .../assets/styles/default/light.mpfstyle.json | 0 .../assets/styles/default/light.mplrc.json | 0 .../assets/styles/default/light.mplstyle | 0 .../assets/styles/default/light.pltstyle.json | 0 .../styles/default/light.richstyle.json | 0 .../styles/default/tables.pltstyle.json | 0 .../assets/styles/user/openbb.richstyle.json | 0 cli/openbb_cli/cli.py | 20 ++++ .../openbb_cli}/config/__init__.py | 0 .../openbb_cli}/config/completer.py | 0 .../openbb_cli}/config/console.py | 10 +- .../openbb_cli}/config/constants.py | 8 +- .../openbb_cli}/config/menu_text.py | 2 +- .../openbb_cli}/config/setup.py | 15 +-- .../openbb_cli}/config/style.py | 2 +- .../controllers/base_controller.py | 31 +++---- .../controllers/base_platform_controller.py | 15 ++- .../openbb_cli}/controllers/choices.py | 14 +-- .../openbb_cli/controllers/cli_controller.py | 87 +++++++++--------- .../controllers/feature_flags_controller.py | 14 +-- .../openbb_cli}/controllers/hub_service.py | 5 +- .../platform_controller_factory.py | 4 +- .../openbb_cli}/controllers/script_parser.py | 3 +- .../openbb_cli}/controllers/utils.py | 33 +++---- .../openbb_cli}/models/settings.py | 5 +- .../openbb_cli}/session.py | 16 ++-- {openbb_terminal => cli}/poetry.lock | 0 {openbb_terminal => cli}/pyproject.toml | 8 +- {openbb_terminal => cli}/tests/__init__.py | 0 frontend-components/plotly/package.json | 2 +- frontend-components/tables/package.json | 2 +- openbb_terminal/openbb_terminal/cli.py | 20 ---- ruff.toml | 8 +- 51 files changed, 162 insertions(+), 221 deletions(-) delete mode 100644 .github/workflows/docker-build.yml rename {openbb_terminal => cli}/CONTRIBUTING.md (100%) rename {openbb_terminal => cli}/README.md (100%) rename {openbb_terminal/openbb_terminal => cli/openbb_cli}/__init__.py (100%) rename {openbb_terminal/openbb_terminal => cli/openbb_cli}/argparse_translator/__init__.py (100%) rename {openbb_terminal/openbb_terminal => cli/openbb_cli}/argparse_translator/argparse_class_processor.py (98%) rename {openbb_terminal/openbb_terminal => cli/openbb_cli}/argparse_translator/argparse_translator.py (100%) rename {openbb_terminal/openbb_terminal => cli/openbb_cli}/argparse_translator/obbject_registry.py (100%) rename {openbb_terminal/openbb_terminal => cli/openbb_cli}/assets/i18n/en.yml (97%) rename {openbb_terminal/openbb_terminal => cli/openbb_cli}/assets/routines/routine_example.openbb (100%) rename {openbb_terminal/openbb_terminal => cli/openbb_cli}/assets/styles/default/Consolas.ttf (100%) rename {openbb_terminal/openbb_terminal => cli/openbb_cli}/assets/styles/default/dark.mpfstyle.json (100%) rename {openbb_terminal/openbb_terminal => cli/openbb_cli}/assets/styles/default/dark.mplrc.json (100%) rename {openbb_terminal/openbb_terminal => cli/openbb_cli}/assets/styles/default/dark.mplstyle (100%) rename {openbb_terminal/openbb_terminal => cli/openbb_cli}/assets/styles/default/dark.pltstyle.json (100%) rename {openbb_terminal/openbb_terminal => cli/openbb_cli}/assets/styles/default/dark.richstyle.json (100%) rename {openbb_terminal/openbb_terminal => cli/openbb_cli}/assets/styles/default/light.mpfstyle.json (100%) rename {openbb_terminal/openbb_terminal => cli/openbb_cli}/assets/styles/default/light.mplrc.json (100%) rename {openbb_terminal/openbb_terminal => cli/openbb_cli}/assets/styles/default/light.mplstyle (100%) rename {openbb_terminal/openbb_terminal => cli/openbb_cli}/assets/styles/default/light.pltstyle.json (100%) rename {openbb_terminal/openbb_terminal => cli/openbb_cli}/assets/styles/default/light.richstyle.json (100%) rename {openbb_terminal/openbb_terminal => cli/openbb_cli}/assets/styles/default/tables.pltstyle.json (100%) rename {openbb_terminal/openbb_terminal => cli/openbb_cli}/assets/styles/user/openbb.richstyle.json (100%) create mode 100644 cli/openbb_cli/cli.py rename {openbb_terminal/openbb_terminal => cli/openbb_cli}/config/__init__.py (100%) rename {openbb_terminal/openbb_terminal => cli/openbb_cli}/config/completer.py (100%) rename {openbb_terminal/openbb_terminal => cli/openbb_cli}/config/console.py (91%) rename {openbb_terminal/openbb_terminal => cli/openbb_cli}/config/constants.py (88%) rename {openbb_terminal/openbb_terminal => cli/openbb_cli}/config/menu_text.py (99%) rename {openbb_terminal/openbb_terminal => cli/openbb_cli}/config/setup.py (80%) rename {openbb_terminal/openbb_terminal => cli/openbb_cli}/config/style.py (98%) rename {openbb_terminal/openbb_terminal => cli/openbb_cli}/controllers/base_controller.py (98%) rename {openbb_terminal/openbb_terminal => cli/openbb_cli}/controllers/base_platform_controller.py (95%) rename {openbb_terminal/openbb_terminal => cli/openbb_cli}/controllers/choices.py (95%) rename openbb_terminal/openbb_terminal/controllers/terminal_controller.py => cli/openbb_cli/controllers/cli_controller.py (94%) rename {openbb_terminal/openbb_terminal => cli/openbb_cli}/controllers/feature_flags_controller.py (96%) rename {openbb_terminal/openbb_terminal => cli/openbb_cli}/controllers/hub_service.py (97%) rename {openbb_terminal/openbb_terminal => cli/openbb_cli}/controllers/platform_controller_factory.py (92%) rename {openbb_terminal/openbb_terminal => cli/openbb_cli}/controllers/script_parser.py (99%) rename {openbb_terminal/openbb_terminal => cli/openbb_cli}/controllers/utils.py (97%) rename {openbb_terminal/openbb_terminal => cli/openbb_cli}/models/settings.py (98%) rename {openbb_terminal/openbb_terminal => cli/openbb_cli}/session.py (84%) rename {openbb_terminal => cli}/poetry.lock (100%) rename {openbb_terminal => cli}/pyproject.toml (81%) rename {openbb_terminal => cli}/tests/__init__.py (100%) delete mode 100644 openbb_terminal/openbb_terminal/cli.py diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml deleted file mode 100644 index 6e69b5d9a6c..00000000000 --- a/.github/workflows/docker-build.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: Build and Publish Docker - -on: workflow_dispatch - -jobs: - publish-image: - runs-on: ubuntu-latest - env: - OPENBBTERMINAL_DOCKER_GITHUB_REPOSITORY: ${{ github.repository }} - OPENBB_LOGGING_APP_NAME: "gst_docker" - - steps: - - name: Checkout Code - uses: actions/checkout@v3 - - - name: Login to GitHub Container Registry - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Setup commit hash - run: | - echo "OPENBB_LOGGING_COMMIT_HASH=sha:$(git rev-parse --short=8 "$GITHUB_SHA")" >> $GITHUB_ENV - - - name: Build env file - run: | - echo "OPENBB_LOGGING_APP_NAME='${OPENBB_LOGGING_APP_NAME}'" > openbb_terminal/.env - echo "OPENBB_LOGGING_COMMIT_HASH='${OPENBB_LOGGING_COMMIT_HASH}'" >> openbb_terminal/.env - cat openbb_terminal/.env - - - name: Building the Docker image - run: | - source build/docker/compose.env - source build/docker/build.sh - echo "OPENBBTERMINAL_DOCKER_POETRY_IMAGE=$OPENBBTERMINAL_DOCKER_POETRY_IMAGE" >> $GITHUB_ENV - echo "OPENBBTERMINAL_DOCKER_POETRY_IMAGE_LATEST=$OPENBBTERMINAL_DOCKER_POETRY_IMAGE_LATEST" >> $GITHUB_ENV - - - name: Publishing the Docker image (release version) - run: | - docker push "${OPENBBTERMINAL_DOCKER_POETRY_IMAGE}" - if: startsWith(github.ref, 'refs/heads/main') - - - name: Publishing the latest Docker image - run: | - docker push "${OPENBBTERMINAL_DOCKER_POETRY_IMAGE_LATEST}" - if: startsWith(github.ref, 'refs/heads/main') diff --git a/.gitignore b/.gitignore index 5160f3f560b..a16c29ef0d3 100644 --- a/.gitignore +++ b/.gitignore @@ -40,15 +40,15 @@ lightning_logs/ */mocked_path *.pem -# Terminal +# CLI *.pyo **/dist/* -build/terminal +build/cli build/nsis/app DMG/* *.dmg *.sh -openbb_terminal/openbb_terminal/assets/styles/user/hub.richstyle.json +cli/openbb_cli/assets/styles/user/hub.richstyle.json # Platform openbb_platform/openbb/package/* diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index da3cfd4d3e9..e16417a185e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -39,7 +39,6 @@ repos: "--ignore-words-list=VAI,MIS,shs,gard,te,commun,parana,ro,zar,vie,hel,jewl,zlot,ba,buil,coo,ether,hist,hsi,mape,navagation,operatio,pres,ser,yeld,shold,ist,varian,datas,ake,creat,statics,ket,toke,certi,buidl,ot,fo", "--quiet-level=2", "--skip=./**/tests/**,./**/test_*.py,.git,*.css,*.csv,*.html,*.ini,*.ipynb,*.js,*.json,*.lock,*.scss,*.txt,*.yaml,build/pyinstaller/*,./website/config.toml", - "-x=openbb_terminal/economy/fedreserve_model.py", "-x=.github/workflows/linting.yml" ] - repo: local diff --git a/openbb_terminal/CONTRIBUTING.md b/cli/CONTRIBUTING.md similarity index 100% rename from openbb_terminal/CONTRIBUTING.md rename to cli/CONTRIBUTING.md diff --git a/openbb_terminal/README.md b/cli/README.md similarity index 100% rename from openbb_terminal/README.md rename to cli/README.md diff --git a/openbb_terminal/openbb_terminal/__init__.py b/cli/openbb_cli/__init__.py similarity index 100% rename from openbb_terminal/openbb_terminal/__init__.py rename to cli/openbb_cli/__init__.py diff --git a/openbb_terminal/openbb_terminal/argparse_translator/__init__.py b/cli/openbb_cli/argparse_translator/__init__.py similarity index 100% rename from openbb_terminal/openbb_terminal/argparse_translator/__init__.py rename to cli/openbb_cli/argparse_translator/__init__.py diff --git a/openbb_terminal/openbb_terminal/argparse_translator/argparse_class_processor.py b/cli/openbb_cli/argparse_translator/argparse_class_processor.py similarity index 98% rename from openbb_terminal/openbb_terminal/argparse_translator/argparse_class_processor.py rename to cli/openbb_cli/argparse_translator/argparse_class_processor.py index 74e706e5ebb..6fff39aa18e 100644 --- a/openbb_terminal/openbb_terminal/argparse_translator/argparse_class_processor.py +++ b/cli/openbb_cli/argparse_translator/argparse_class_processor.py @@ -4,7 +4,7 @@ from typing import Any, Dict, Optional, Type # TODO: this needs to be done differently from openbb_core.app.static.container import Container -from openbb_terminal.argparse_translator.argparse_translator import ( +from openbb_cli.argparse_translator.argparse_translator import ( ArgparseTranslator, ReferenceToCustomArgumentsProcessor, ) diff --git a/openbb_terminal/openbb_terminal/argparse_translator/argparse_translator.py b/cli/openbb_cli/argparse_translator/argparse_translator.py similarity index 100% rename from openbb_terminal/openbb_terminal/argparse_translator/argparse_translator.py rename to cli/openbb_cli/argparse_translator/argparse_translator.py diff --git a/openbb_terminal/openbb_terminal/argparse_translator/obbject_registry.py b/cli/openbb_cli/argparse_translator/obbject_registry.py similarity index 100% rename from openbb_terminal/openbb_terminal/argparse_translator/obbject_registry.py rename to cli/openbb_cli/argparse_translator/obbject_registry.py diff --git a/openbb_terminal/openbb_terminal/assets/i18n/en.yml b/cli/openbb_cli/assets/i18n/en.yml similarity index 97% rename from openbb_terminal/openbb_terminal/assets/i18n/en.yml rename to cli/openbb_cli/assets/i18n/en.yml index beb4013229d..a8d06e45b88 100644 --- a/openbb_terminal/openbb_terminal/assets/i18n/en.yml +++ b/cli/openbb_cli/assets/i18n/en.yml @@ -11,7 +11,7 @@ en: _configure_: Configure your own CLI _main_menu_: Main menu settings/_info_: Feature flags - settings/_settings_: Terminal settings and preferences + settings/_settings_: Settings and preferences settings/retryload: retry misspelled commands with load first settings/interactive: open dataframes in interactive window settings/cls: clear console after each command diff --git a/openbb_terminal/openbb_terminal/assets/routines/routine_example.openbb b/cli/openbb_cli/assets/routines/routine_example.openbb similarity index 100% rename from openbb_terminal/openbb_terminal/assets/routines/routine_example.openbb rename to cli/openbb_cli/assets/routines/routine_example.openbb diff --git a/openbb_terminal/openbb_terminal/assets/styles/default/Consolas.ttf b/cli/openbb_cli/assets/styles/default/Consolas.ttf similarity index 100% rename from openbb_terminal/openbb_terminal/assets/styles/default/Consolas.ttf rename to cli/openbb_cli/assets/styles/default/Consolas.ttf diff --git a/openbb_terminal/openbb_terminal/assets/styles/default/dark.mpfstyle.json b/cli/openbb_cli/assets/styles/default/dark.mpfstyle.json similarity index 100% rename from openbb_terminal/openbb_terminal/assets/styles/default/dark.mpfstyle.json rename to cli/openbb_cli/assets/styles/default/dark.mpfstyle.json diff --git a/openbb_terminal/openbb_terminal/assets/styles/default/dark.mplrc.json b/cli/openbb_cli/assets/styles/default/dark.mplrc.json similarity index 100% rename from openbb_terminal/openbb_terminal/assets/styles/default/dark.mplrc.json rename to cli/openbb_cli/assets/styles/default/dark.mplrc.json diff --git a/openbb_terminal/openbb_terminal/assets/styles/default/dark.mplstyle b/cli/openbb_cli/assets/styles/default/dark.mplstyle similarity index 100% rename from openbb_terminal/openbb_terminal/assets/styles/default/dark.mplstyle rename to cli/openbb_cli/assets/styles/default/dark.mplstyle diff --git a/openbb_terminal/openbb_terminal/assets/styles/default/dark.pltstyle.json b/cli/openbb_cli/assets/styles/default/dark.pltstyle.json similarity index 100% rename from openbb_terminal/openbb_terminal/assets/styles/default/dark.pltstyle.json rename to cli/openbb_cli/assets/styles/default/dark.pltstyle.json diff --git a/openbb_terminal/openbb_terminal/assets/styles/default/dark.richstyle.json b/cli/openbb_cli/assets/styles/default/dark.richstyle.json similarity index 100% rename from openbb_terminal/openbb_terminal/assets/styles/default/dark.richstyle.json rename to cli/openbb_cli/assets/styles/default/dark.richstyle.json diff --git a/openbb_terminal/openbb_terminal/assets/styles/default/light.mpfstyle.json b/cli/openbb_cli/assets/styles/default/light.mpfstyle.json similarity index 100% rename from openbb_terminal/openbb_terminal/assets/styles/default/light.mpfstyle.json rename to cli/openbb_cli/assets/styles/default/light.mpfstyle.json diff --git a/openbb_terminal/openbb_terminal/assets/styles/default/light.mplrc.json b/cli/openbb_cli/assets/styles/default/light.mplrc.json similarity index 100% rename from openbb_terminal/openbb_terminal/assets/styles/default/light.mplrc.json rename to cli/openbb_cli/assets/styles/default/light.mplrc.json diff --git a/openbb_terminal/openbb_terminal/assets/styles/default/light.mplstyle b/cli/openbb_cli/assets/styles/default/light.mplstyle similarity index 100% rename from openbb_terminal/openbb_terminal/assets/styles/default/light.mplstyle rename to cli/openbb_cli/assets/styles/default/light.mplstyle diff --git a/openbb_terminal/openbb_terminal/assets/styles/default/light.pltstyle.json b/cli/openbb_cli/assets/styles/default/light.pltstyle.json similarity index 100% rename from openbb_terminal/openbb_terminal/assets/styles/default/light.pltstyle.json rename to cli/openbb_cli/assets/styles/default/light.pltstyle.json diff --git a/openbb_terminal/openbb_terminal/assets/styles/default/light.richstyle.json b/cli/openbb_cli/assets/styles/default/light.richstyle.json similarity index 100% rename from openbb_terminal/openbb_terminal/assets/styles/default/light.richstyle.json rename to cli/openbb_cli/assets/styles/default/light.richstyle.json diff --git a/openbb_terminal/openbb_terminal/assets/styles/default/tables.pltstyle.json b/cli/openbb_cli/assets/styles/default/tables.pltstyle.json similarity index 100% rename from openbb_terminal/openbb_terminal/assets/styles/default/tables.pltstyle.json rename to cli/openbb_cli/assets/styles/default/tables.pltstyle.json diff --git a/openbb_terminal/openbb_terminal/assets/styles/user/openbb.richstyle.json b/cli/openbb_cli/assets/styles/user/openbb.richstyle.json similarity index 100% rename from openbb_terminal/openbb_terminal/assets/styles/user/openbb.richstyle.json rename to cli/openbb_cli/assets/styles/user/openbb.richstyle.json diff --git a/cli/openbb_cli/cli.py b/cli/openbb_cli/cli.py new file mode 100644 index 00000000000..c301be893f9 --- /dev/null +++ b/cli/openbb_cli/cli.py @@ -0,0 +1,20 @@ +"""OpenBB Platform CLI entry point.""" + +import sys + +from openbb_cli.config.setup import bootstrap +from openbb_cli.controllers.cli_controller import launch + + +def main(): + """Use the main entry point for the OpenBB CLI.""" + bootstrap() + + dev = "--dev" in sys.argv[1:] + debug = "--debug" in sys.argv[1:] + + launch(dev, debug) + + +if __name__ == "__main__": + main() diff --git a/openbb_terminal/openbb_terminal/config/__init__.py b/cli/openbb_cli/config/__init__.py similarity index 100% rename from openbb_terminal/openbb_terminal/config/__init__.py rename to cli/openbb_cli/config/__init__.py diff --git a/openbb_terminal/openbb_terminal/config/completer.py b/cli/openbb_cli/config/completer.py similarity index 100% rename from openbb_terminal/openbb_terminal/config/completer.py rename to cli/openbb_cli/config/completer.py diff --git a/openbb_terminal/openbb_terminal/config/console.py b/cli/openbb_cli/config/console.py similarity index 91% rename from openbb_terminal/openbb_terminal/config/console.py rename to cli/openbb_cli/config/console.py index 749e40c0a3b..f19904cedc4 100644 --- a/openbb_terminal/openbb_terminal/config/console.py +++ b/cli/openbb_cli/config/console.py @@ -1,4 +1,4 @@ -from typing import TYPE_CHECKING, Optional, Tuple +from typing import TYPE_CHECKING, Any, Dict, Optional, Tuple from rich import panel from rich.console import ( @@ -7,10 +7,10 @@ from rich.console import ( ) from rich.text import Text -from openbb_terminal.config.menu_text import RICH_TAGS +from openbb_cli.config.menu_text import RICH_TAGS if TYPE_CHECKING: - from openbb_terminal.models.settings import Settings + from openbb_cli.models.settings import Settings class Console: @@ -19,11 +19,11 @@ class Console: def __init__( self, settings: "Settings", - style: Optional[str] = None, + style: Optional[Dict[str, Any]] = None, ): """Initialize the ConsoleAndPanel class.""" self._console = RichConsole( - theme=Theme(style), # type: ignore[arg-type] + theme=Theme(style), highlight=False, soft_wrap=True, ) diff --git a/openbb_terminal/openbb_terminal/config/constants.py b/cli/openbb_cli/config/constants.py similarity index 88% rename from openbb_terminal/openbb_terminal/config/constants.py rename to cli/openbb_cli/config/constants.py index 462dae59c0a..c44150324f3 100644 --- a/openbb_terminal/openbb_terminal/config/constants.py +++ b/cli/openbb_cli/config/constants.py @@ -6,13 +6,13 @@ from pathlib import Path HOME_DIRECTORY = Path.home() REPOSITORY_DIRECTORY = Path(__file__).parent.parent.parent.parent SRC_DIRECTORY = Path(__file__).parent.parent -SETTINGS_DIRECTORY = HOME_DIRECTORY / ".openbb_terminal" +SETTINGS_DIRECTORY = HOME_DIRECTORY / ".openbb_platform" ASSETS_DIRECTORY = SRC_DIRECTORY / "assets" STYLES_DIRECTORY = ASSETS_DIRECTORY / "styles" ENV_FILE_REPOSITORY = REPOSITORY_DIRECTORY / ".env" -ENV_FILE_PROJECT = REPOSITORY_DIRECTORY / "openbb_terminal" / ".env" -ENV_FILE_SETTINGS = SETTINGS_DIRECTORY / ".env" -HIST_FILE_PROMPT = SETTINGS_DIRECTORY / ".openbb_terminal.his" +ENV_FILE_PROJECT = REPOSITORY_DIRECTORY / "openbb_cli" / ".env" +ENV_FILE_SETTINGS = SETTINGS_DIRECTORY / ".cli.env" +HIST_FILE_PROMPT = SETTINGS_DIRECTORY / ".cli.his" I18N_FILE = ASSETS_DIRECTORY / "i18n" diff --git a/openbb_terminal/openbb_terminal/config/menu_text.py b/cli/openbb_cli/config/menu_text.py similarity index 99% rename from openbb_terminal/openbb_terminal/config/menu_text.py rename to cli/openbb_cli/config/menu_text.py index bd6234097d6..39bfa5787e9 100644 --- a/openbb_terminal/openbb_terminal/config/menu_text.py +++ b/cli/openbb_cli/config/menu_text.py @@ -50,7 +50,7 @@ def get_ordered_list_sources(command_path: str) -> List: class MenuText: - """Create menu text with rich colors to be displayed by terminal.""" + """Create menu text with rich colors to be displayed by CLI.""" def __init__(self, path: str = "", column_sources: int = 100): """Initialize menu help. diff --git a/openbb_terminal/openbb_terminal/config/setup.py b/cli/openbb_cli/config/setup.py similarity index 80% rename from openbb_terminal/openbb_terminal/config/setup.py rename to cli/openbb_cli/config/setup.py index c6547a62d59..09bbe505270 100644 --- a/openbb_terminal/openbb_terminal/config/setup.py +++ b/cli/openbb_cli/config/setup.py @@ -1,4 +1,4 @@ -"""Configuration for the terminal.""" +"""Configuration for the CLI.""" import copy from pathlib import Path @@ -6,7 +6,8 @@ from typing import TYPE_CHECKING, List, Optional, TypeVar import i18n -from openbb_terminal.config.constants import I18N_FILE +from openbb_cli.config.constants import ENV_FILE_SETTINGS, I18N_FILE, SETTINGS_DIRECTORY +from openbb_cli.session import Session if TYPE_CHECKING: from openbb_charting.core.openbb_figure import OpenBBFigure @@ -70,15 +71,15 @@ def set_current_figure(fig: Optional[OpenBBFigureT] = None): def setup_i18n(i18n_path: Path = I18N_FILE, lang: str = "en"): - """Select the terminal translation language.""" + """Select the CLI translation language.""" i18n.load_path.append(i18n_path) i18n.set("locale", lang) i18n.set("filename_format", "{locale}.{format}") -def setup_config_terminal(): - """Setup pre-launch configurations for the terminal.""" - # pylint: disable=import-outside-toplevel - from openbb_terminal.session import Session +def bootstrap(): + """Setup pre-launch configurations for the CLI.""" + SETTINGS_DIRECTORY.mkdir(parents=True, exist_ok=True) + Path(ENV_FILE_SETTINGS).touch(exist_ok=True) setup_i18n(lang=Session().settings.USE_LANGUAGE) diff --git a/openbb_terminal/openbb_terminal/config/style.py b/cli/openbb_cli/config/style.py similarity index 98% rename from openbb_terminal/openbb_terminal/config/style.py rename to cli/openbb_cli/config/style.py index dccdf0bda2b..439d2a410d4 100644 --- a/openbb_terminal/openbb_terminal/config/style.py +++ b/cli/openbb_cli/config/style.py @@ -7,7 +7,7 @@ from typing import Any, Dict, List, Optional from rich.console import Console -from openbb_terminal.config.constants import STYLES_DIRECTORY +from openbb_cli.config.constants import STYLES_DIRECTORY console = Console() diff --git a/openbb_terminal/openbb_terminal/controllers/base_controller.py b/cli/openbb_cli/controllers/base_controller.py similarity index 98% rename from openbb_terminal/openbb_terminal/controllers/base_controller.py rename to cli/openbb_cli/controllers/base_controller.py index 21759214b29..7d0c3fe27cc 100644 --- a/openbb_terminal/openbb_terminal/controllers/base_controller.py +++ b/cli/openbb_cli/controllers/base_controller.py @@ -1,4 +1,4 @@ -"""Base controller for the terminal.""" +"""Base controller for the CLI.""" import argparse import difflib @@ -9,15 +9,12 @@ from datetime import datetime from pathlib import Path from typing import Any, Dict, List, Literal, Optional, Union -from prompt_toolkit.formatted_text import HTML -from prompt_toolkit.styles import Style - -from openbb_terminal.config import setup -from openbb_terminal.config.completer import NestedCompleter -from openbb_terminal.config.constants import SCRIPT_TAGS -from openbb_terminal.controllers.choices import build_controller_choice_map -from openbb_terminal.controllers.hub_service import upload_routine -from openbb_terminal.controllers.utils import ( +from openbb_cli.config import setup +from openbb_cli.config.completer import NestedCompleter +from openbb_cli.config.constants import SCRIPT_TAGS +from openbb_cli.controllers.choices import build_controller_choice_map +from openbb_cli.controllers.hub_service import upload_routine +from openbb_cli.controllers.utils import ( check_file_type_saved, check_positive, get_flair_and_username, @@ -26,7 +23,9 @@ from openbb_terminal.controllers.utils import ( remove_file, system_clear, ) -from openbb_terminal.session import Session +from openbb_cli.session import Session +from prompt_toolkit.formatted_text import HTML +from prompt_toolkit.styles import Style # pylint: disable=C0301,C0302,R0902,global-statement,too-many-boolean-expressions # pylint: disable=R0912 @@ -45,7 +44,7 @@ SESSION_RECORDED_PUBLIC = False class BaseController(metaclass=ABCMeta): - """Base class for a terminal controller.""" + """Base class for a cli controller.""" CHOICES_COMMON = [ "cls", @@ -114,7 +113,7 @@ class BaseController(metaclass=ABCMeta): self.parser = argparse.ArgumentParser( add_help=False, - prog=self.path[-1] if self.PATH != "/" else "terminal", + prog=self.path[-1] if self.PATH != "/" else "cli", ) self.parser.exit_on_error = False # type: ignore self.parser.add_argument("cmd", choices=self.controller_choices) @@ -402,7 +401,7 @@ class BaseController(metaclass=ABCMeta): def call_exit(self, _) -> None: # Not sure how to handle controller loading here - """Process exit terminal command.""" + """Process exit cli command.""" self.save_class() for _ in range(self.PATH.count("/")): self.queue.insert(0, "quit") @@ -493,7 +492,7 @@ class BaseController(metaclass=ABCMeta): "--local", dest="local", action="store_true", - help="Only save the routine locally - this is necessary if you are running terminal in guest mode.", + help="Only save the routine locally - this is necessary if you are running in guest mode.", default=False, ) if other_args and "-" not in other_args[0][0]: @@ -971,7 +970,7 @@ class BaseController(metaclass=ABCMeta): bottom_toolbar=HTML( ' help menu ' ' return to previous menu ' - ' exit terminal ' + ' exit the program ' ' ' "see usage and available options " f' ' diff --git a/openbb_terminal/openbb_terminal/controllers/base_platform_controller.py b/cli/openbb_cli/controllers/base_platform_controller.py similarity index 95% rename from openbb_terminal/openbb_terminal/controllers/base_platform_controller.py rename to cli/openbb_cli/controllers/base_platform_controller.py index 03516a4421e..50476a68460 100644 --- a/openbb_terminal/openbb_terminal/controllers/base_platform_controller.py +++ b/cli/openbb_cli/controllers/base_platform_controller.py @@ -8,16 +8,15 @@ from typing import Dict, List, Optional import pandas as pd from openbb import obb from openbb_charting.core.openbb_figure import OpenBBFigure - -from openbb_terminal.argparse_translator.argparse_class_processor import ( +from openbb_cli.argparse_translator.argparse_class_processor import ( ArgparseClassProcessor, ) -from openbb_terminal.argparse_translator.obbject_registry import Registry -from openbb_terminal.config.completer import NestedCompleter -from openbb_terminal.config.menu_text import MenuText -from openbb_terminal.controllers.base_controller import BaseController -from openbb_terminal.controllers.utils import export_data, print_rich_table -from openbb_terminal.session import Session +from openbb_cli.argparse_translator.obbject_registry import Registry +from openbb_cli.config.completer import NestedCompleter +from openbb_cli.config.menu_text import MenuText +from openbb_cli.controllers.base_controller import BaseController +from openbb_cli.controllers.utils import export_data, print_rich_table +from openbb_cli.session import Session class DummyTranslation: diff --git a/openbb_terminal/openbb_terminal/controllers/choices.py b/cli/openbb_cli/controllers/choices.py similarity index 95% rename from openbb_terminal/openbb_terminal/controllers/choices.py rename to cli/openbb_cli/controllers/choices.py index ba3def5a3c2..7e66660ff79 100644 --- a/openbb_terminal/openbb_terminal/controllers/choices.py +++ b/cli/openbb_cli/controllers/choices.py @@ -7,11 +7,11 @@ from types import MethodType from typing import Callable, List, Literal from unittest.mock import patch -from openbb_terminal.controllers.utils import ( +from openbb_cli.controllers.utils import ( check_file_type_saved, check_positive, ) -from openbb_terminal.session import Session +from openbb_cli.session import Session def __mock_parse_known_args_and_warn( @@ -27,7 +27,7 @@ def __mock_parse_known_args_and_warn( """Add arguments. Add the arguments that would have normally added by : - - openbb_terminal.parent_classes.BaseController.parse_known_args_and_warn + - openbb_cli.base_controller.BaseController.parse_known_args_and_warn Parameters ---------- @@ -94,7 +94,7 @@ def __mock_parse_simple_args(parser: ArgumentParser, other_args: List[str]) -> N """Add arguments. Add the arguments that would have normally added by: - - openbb_terminal.parent_classes.BaseController.parse_simple_args + - openbb_cli.parent_classes.BaseController.parse_simple_args Parameters ---------- @@ -115,7 +115,7 @@ def __get_command_func(controller, command: str): Parameters ---------- controller: BaseController - Instance of the Terminal Controller. + Instance of the CLI Controller. command: str A name from controller.CHOICES_COMMANDS @@ -187,7 +187,7 @@ def __patch_controller_functions(controller): ) rich = patch( - target="openbb_terminal.config.console.Console.print", + target="openbb_cli.config.console.Console.print", return_value=None, ) @@ -234,7 +234,7 @@ def _get_argument_parser( Parameters ---------- controller: BaseController - Instance of the Terminal Controller. + Instance of the CLI Controller. command: str A name from `controller.CHOICES_COMMANDS`. diff --git a/openbb_terminal/openbb_terminal/controllers/terminal_controller.py b/cli/openbb_cli/controllers/cli_controller.py similarity index 94% rename from openbb_terminal/openbb_terminal/controllers/terminal_controller.py rename to cli/openbb_cli/controllers/cli_controller.py index 1cea3c31a1a..f6e0998fc2a 100644 --- a/openbb_terminal/openbb_terminal/controllers/terminal_controller.py +++ b/cli/openbb_cli/controllers/cli_controller.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -"""Main Terminal Module.""" +"""Main CLI Module.""" import argparse import contextlib @@ -20,26 +20,22 @@ import certifi import pandas as pd import requests from openbb import obb -from prompt_toolkit.formatted_text import HTML -from prompt_toolkit.styles import Style -from pydantic import BaseModel - -from openbb_terminal.argparse_translator.obbject_registry import Registry -from openbb_terminal.config import constants -from openbb_terminal.config.completer import NestedCompleter -from openbb_terminal.config.constants import ( +from openbb_cli.argparse_translator.obbject_registry import Registry +from openbb_cli.config import constants +from openbb_cli.config.completer import NestedCompleter +from openbb_cli.config.constants import ( ASSETS_DIRECTORY, ENV_FILE_SETTINGS, HOME_DIRECTORY, REPOSITORY_DIRECTORY, ) -from openbb_terminal.config.menu_text import MenuText -from openbb_terminal.controllers.base_controller import BaseController -from openbb_terminal.controllers.platform_controller_factory import ( +from openbb_cli.config.menu_text import MenuText +from openbb_cli.controllers.base_controller import BaseController +from openbb_cli.controllers.platform_controller_factory import ( PlatformControllerFactory, ) -from openbb_terminal.controllers.script_parser import is_reset, parse_openbb_script -from openbb_terminal.controllers.utils import ( +from openbb_cli.controllers.script_parser import is_reset, parse_openbb_script +from openbb_cli.controllers.utils import ( bootup, first_time_user, get_flair_and_username, @@ -51,7 +47,10 @@ from openbb_terminal.controllers.utils import ( suppress_stdout, welcome_message, ) -from openbb_terminal.session import Session +from openbb_cli.session import Session +from prompt_toolkit.formatted_text import HTML +from prompt_toolkit.styles import Style +from pydantic import BaseModel PLATFORM_ROUTERS = { d: "menu" if not isinstance(getattr(obb, d), BaseModel) else "command" @@ -76,8 +75,8 @@ if is_installer(): os.environ["SSL_CERT_FILE"] = certifi.where() -class TerminalController(BaseController): - """Terminal Controller class.""" +class CLIController(BaseController): + """CLI Controller class.""" CHOICES_COMMANDS = ["record", "stop", "exe", "results"] CHOICES_MENUS = [ @@ -94,7 +93,7 @@ class TerminalController(BaseController): CHOICES_GENERATION = False def __init__(self, jobs_cmds: Optional[List[str]] = None): - """Construct terminal controller.""" + """Construct CLI controller.""" self.ROUTINE_FILES: Dict[str, str] = dict() self.ROUTINE_DEFAULT_FILES: Dict[str, str] = dict() self.ROUTINE_PERSONAL_FILES: Dict[str, str] = dict() @@ -303,7 +302,7 @@ class TerminalController(BaseController): def call_settings(self, _): """Process feature flags command.""" - from openbb_terminal.controllers.feature_flags_controller import ( + from openbb_cli.controllers.feature_flags_controller import ( FeatureFlagsController, ) @@ -492,7 +491,7 @@ class TerminalController(BaseController): def handle_job_cmds(jobs_cmds: Optional[List[str]]) -> Optional[List[str]]: """Handle job commands.""" # If the path selected does not start from the user root, - # give relative location from terminal root + # give relative location from root if jobs_cmds is not None and jobs_cmds: logger.info("INPUT: %s", "/".join(jobs_cmds)) @@ -526,10 +525,10 @@ def handle_job_cmds(jobs_cmds: Optional[List[str]]) -> Optional[List[str]]: # pylint: disable=unused-argument -def terminal(jobs_cmds: Optional[List[str]] = None, test_mode=False): - """Run the terminal menu.""" +def run_cli(jobs_cmds: Optional[List[str]] = None, test_mode=False): + """Run the CLI menu.""" ret_code = 1 - t_controller = TerminalController(jobs_cmds) + t_controller = CLIController(jobs_cmds) an_input = "" jobs_cmds = handle_job_cmds(jobs_cmds) @@ -570,14 +569,14 @@ def terminal(jobs_cmds: Optional[List[str]] = None, test_mode=False): if Session().prompt_session and Session().settings.USE_PROMPT_TOOLKIT: # Check if toolbar hint was enabled if Session().settings.TOOLBAR_HINT: - an_input = Session().prompt_session.prompt( + an_input = Session().prompt_session.prompt( # type: ignore[union-attr] f"{get_flair_and_username()} / $ ", completer=t_controller.completer, search_ignore_case=True, bottom_toolbar=HTML( ' help menu ' ' return to previous menu ' - ' exit terminal ' + ' exit the program ' ' ' "see usage and available options " ' ' @@ -589,7 +588,7 @@ def terminal(jobs_cmds: Optional[List[str]] = None, test_mode=False): ), ) else: - an_input = Session().prompt_session.prompt( + an_input = Session().prompt_session.prompt( # type: ignore[union-attr] f"{get_flair_and_username()} / $ ", completer=t_controller.completer, search_ignore_case=True, @@ -671,7 +670,7 @@ def run_scripts( path : str The location of the .openbb file test_mode : bool - Whether the terminal is in test mode + Whether the CLI is in test mode verbose : bool Whether to run tests in verbose mode routines_args : List[str] @@ -683,11 +682,9 @@ def run_scripts( Whether to log tests to txt files """ if not path.exists(): - Session().console.print( - f"File '{path}' doesn't exist. Launching base terminal.\n" - ) + Session().console.print(f"File '{path}' doesn't exist. Launching base CLI.\n") if not test_mode: - terminal() + run_cli() # THIS NEEDS TO BE REFACTORED!!! - ITS USED FOR TESTING with path.open() as fp: @@ -736,7 +733,7 @@ def run_scripts( ) if not test_mode or verbose: - terminal(file_cmds, test_mode=True) + run_cli(file_cmds, test_mode=True) else: with suppress_stdout(): Session().console.print(f"To ensure: {output}") @@ -749,9 +746,9 @@ def run_scripts( with open( whole_path / f"{stamp_str}_{first_cmd}_output.txt", "w" ) as output_file, contextlib.redirect_stdout(output_file): - terminal(file_cmds, test_mode=True) + run_cli(file_cmds, test_mode=True) else: - terminal(file_cmds, test_mode=True) + run_cli(file_cmds, test_mode=True) def replace_dynamic(match: re.Match, special_arguments: Dict[str, str]) -> str: @@ -780,7 +777,7 @@ def replace_dynamic(match: re.Match, special_arguments: Dict[str, str]) -> str: def run_routine(file: str, routines_args=Optional[str]): """Execute command routine from .openbb file.""" - user_routine_path = Path(Session().user().preferences.export_directory, "routines") + user_routine_path = Path(Session().user.preferences.export_directory, "routines") default_routine_path = ASSETS_DIRECTORY / "routines" / file if user_routine_path.exists(): @@ -801,16 +798,16 @@ def main( routines_args: Optional[List[str]] = None, **kwargs, ): - """Run the terminal with various options. + """Run the CLI with various options. Parameters ---------- debug : bool - Whether to run the terminal in debug mode + Whether to run the CLI in debug mode dev: Points backend towards development environment instead of production test : bool - Whether to run the terminal in integrated test mode + Whether to run the CLI in integrated test mode filtert : str Filter test files with given string in name paths : List[str] @@ -834,16 +831,16 @@ def main( elif path_list: argv_cmds = list([" ".join(path_list).replace(" /", "/home/")]) argv_cmds = insert_start_slash(argv_cmds) if argv_cmds else argv_cmds - terminal(argv_cmds) + run_cli(argv_cmds) else: - terminal() + run_cli() def parse_args_and_run(): - """Parse input arguments and run terminal.""" + """Parse input arguments and run CLI.""" parser = argparse.ArgumentParser( formatter_class=argparse.ArgumentDefaultsHelpFormatter, - prog="terminal", + prog="cli", description="The OpenBB Platform CLI.", ) parser.add_argument( @@ -885,7 +882,7 @@ def parse_args_and_run(): "--test", action="store_true", help=( - "Run the terminal in testing mode. Also run this option and '-h'" + "Run the CLI in testing mode. Also run this option and '-h'" " to see testing argument options." ), ) @@ -916,7 +913,7 @@ def parse_args_and_run(): sys.argv.insert(1, "--file") ns_parser, unknown = parser.parse_known_args() - # This ensures that if terminal.py receives unknown args it will not start. + # This ensures that if cli.py receives unknown args it will not start. # Use -d flag if you want to see the unknown args. if unknown: if ns_parser.debug: @@ -938,7 +935,7 @@ def parse_args_and_run(): def launch( debug: bool = False, dev: bool = False, queue: Optional[List[str]] = None ) -> None: - """Launch terminal.""" + """Launch CLI.""" if queue: main(debug, dev, queue, module="") diff --git a/openbb_terminal/openbb_terminal/controllers/feature_flags_controller.py b/cli/openbb_cli/controllers/feature_flags_controller.py similarity index 96% rename from openbb_terminal/openbb_terminal/controllers/feature_flags_controller.py rename to cli/openbb_cli/controllers/feature_flags_controller.py index 86a0e3c7e37..860cd98a819 100644 --- a/openbb_terminal/openbb_terminal/controllers/feature_flags_controller.py +++ b/cli/openbb_cli/controllers/feature_flags_controller.py @@ -3,15 +3,15 @@ import argparse from typing import List, Optional -from openbb_terminal.config.completer import NestedCompleter -from openbb_terminal.config.constants import AVAILABLE_FLAIRS -from openbb_terminal.config.menu_text import MenuText +from openbb_cli.config.completer import NestedCompleter +from openbb_cli.config.constants import AVAILABLE_FLAIRS +from openbb_cli.config.menu_text import MenuText # pylint: disable=too-many-lines,no-member,too-many-public-methods,C0302 # pylint:disable=import-outside-toplevel -from openbb_terminal.controllers.base_controller import BaseController -from openbb_terminal.controllers.utils import all_timezones, is_timezone_valid -from openbb_terminal.session import Session +from openbb_cli.controllers.base_controller import BaseController +from openbb_cli.controllers.utils import all_timezones, is_timezone_valid +from openbb_cli.session import Session class FeatureFlagsController(BaseController): @@ -131,7 +131,7 @@ class FeatureFlagsController(BaseController): def call_tbhint(self, _): """Process tbhint command.""" if Session().settings.TOOLBAR_HINT: - Session().console.print("Will take effect when running terminal next.") + Session().console.print("Will take effect when running CLI again.") Session().settings.set_item("TOOLBAR_HINT", not Session().settings.TOOLBAR_HINT) def call_console_style(self, other_args: List[str]) -> None: diff --git a/openbb_terminal/openbb_terminal/controllers/hub_service.py b/cli/openbb_cli/controllers/hub_service.py similarity index 97% rename from openbb_terminal/openbb_terminal/controllers/hub_service.py rename to cli/openbb_cli/controllers/hub_service.py index c5270c3cb36..aa44ebcc41c 100644 --- a/openbb_terminal/openbb_terminal/controllers/hub_service.py +++ b/cli/openbb_cli/controllers/hub_service.py @@ -3,13 +3,12 @@ from typing import Optional import requests - -from openbb_terminal.config.constants import ( +from openbb_cli.config.constants import ( CONNECTION_ERROR_MSG, CONNECTION_TIMEOUT_MSG, TIMEOUT, ) -from openbb_terminal.session import Session +from openbb_cli.session import Session # created dictionaries for personal and default routines with the structure # {"file_name" :["script","personal/default"]} diff --git a/openbb_terminal/openbb_terminal/controllers/platform_controller_factory.py b/cli/openbb_cli/controllers/platform_controller_factory.py similarity index 92% rename from openbb_terminal/openbb_terminal/controllers/platform_controller_factory.py rename to cli/openbb_cli/controllers/platform_controller_factory.py index d1b613c7806..76d43688c01 100644 --- a/openbb_terminal/openbb_terminal/controllers/platform_controller_factory.py +++ b/cli/openbb_cli/controllers/platform_controller_factory.py @@ -2,10 +2,10 @@ from typing import Dict, List, Union -from openbb_terminal.argparse_translator.argparse_class_processor import ( +from openbb_cli.argparse_translator.argparse_class_processor import ( ArgparseClassProcessor, ) -from openbb_terminal.controllers.base_platform_controller import PlatformController +from openbb_cli.controllers.base_platform_controller import PlatformController class PlatformControllerFactory: diff --git a/openbb_terminal/openbb_terminal/controllers/script_parser.py b/cli/openbb_cli/controllers/script_parser.py similarity index 99% rename from openbb_terminal/openbb_terminal/controllers/script_parser.py rename to cli/openbb_cli/controllers/script_parser.py index c182e9f43c3..1dd48925253 100644 --- a/openbb_terminal/openbb_terminal/controllers/script_parser.py +++ b/cli/openbb_cli/controllers/script_parser.py @@ -5,8 +5,7 @@ from datetime import datetime, timedelta from typing import Dict, List, Match, Optional, Tuple, Union from dateutil.relativedelta import relativedelta - -from openbb_terminal.session import Session +from openbb_cli.session import Session # pylint: disable=too-many-statements,eval-used,consider-iterating-dictionary # pylint: disable=too-many-branches,too-many-return-statements diff --git a/openbb_terminal/openbb_terminal/controllers/utils.py b/cli/openbb_cli/controllers/utils.py similarity index 97% rename from openbb_terminal/openbb_terminal/controllers/utils.py rename to cli/openbb_cli/controllers/utils.py index 1ef3fb4e4e4..a85751a58fa 100644 --- a/openbb_terminal/openbb_terminal/controllers/utils.py +++ b/cli/openbb_cli/controllers/utils.py @@ -1,4 +1,4 @@ -"""Terminal utils.""" +"""Utils.""" import argparse import os @@ -18,14 +18,13 @@ import pandas as pd import requests from openbb import obb from openbb_charting.core.backend import create_backend, get_backend +from openbb_cli.config.constants import AVAILABLE_FLAIRS, ENV_FILE_SETTINGS +from openbb_cli.session import Session from openbb_core.app.model.charts.charting_settings import ChartingSettings from packaging import version from pytz import all_timezones, timezone from rich.table import Table -from openbb_terminal.config.constants import AVAILABLE_FLAIRS, ENV_FILE_SETTINGS -from openbb_terminal.session import Session - if TYPE_CHECKING: from openbb_charting.core.openbb_figure import OpenBBFigure @@ -102,14 +101,14 @@ def hide_splashscreen(): try: import pyi_splash # type: ignore # pylint: disable=import-outside-toplevel - pyi_splash.update_text("Terminal Loaded!") + pyi_splash.update_text("CLI Loaded!") pyi_splash.close() except Exception as e: Session().console.print(f"Error: Unable to hide splashscreen: {e}") def print_guest_block_msg(): - """Block guest users from using the terminal.""" + """Block guest users from using the cli.""" if Session().is_local(): Session().console.print( "[info]You are currently logged as a guest.[/info]\n" @@ -125,7 +124,7 @@ def is_installer() -> bool: def bootup(): - """Bootup the terminal.""" + """Bootup the cli.""" if sys.platform == "win32": # Enable VT100 Escape Sequence for WINDOWS 10 Ver. 1607 os.system("") # nosec # noqa: S605,S607 @@ -236,21 +235,21 @@ def reset(queue: Optional[List[str]] = None): # if not get_current_user().profile.remember: # Local.remove(HIST_FILE_PROMPT) - # we clear all openbb_terminal modules from sys.modules + # we clear all openbb_cli modules from sys.modules for module in list(sys.modules.keys()): parts = module.split(".") - if parts[0] == "openbb_terminal": + if parts[0] == "openbb_cli": del sys.modules[module] queue_list = ["/".join(queue) if len(queue) > 0 else ""] # type: ignore # pylint: disable=import-outside-toplevel - # we run the terminal again + # we run the cli again if Session().is_local(): - from openbb_terminal.controllers.terminal_controller import main + from openbb_cli.controllers.cli_controller import main main(debug, dev, queue_list, module="") # type: ignore else: - from openbb_terminal.controllers.terminal_controller import launch + from openbb_cli.controllers.cli_controller import launch launch(queue=queue_list) @@ -819,8 +818,8 @@ def compose_export_path(func_name: str, dir_path: str) -> Path: # Resolving all symlinks and also normalizing path. resolve_path = Path(dir_path).resolve() # Getting the directory names from the path. Instead of using split/replace (Windows doesn't like that) - # check if this is done in a main context to avoid saving with openbb_terminal - if resolve_path.parts[-2] == "openbb_terminal": + # check if this is done in a main context to avoid saving with openbb_cli + if resolve_path.parts[-2] == "openbb_cli": path_cmd = f"{resolve_path.parts[-1]}" else: path_cmd = f"{resolve_path.parts[-2]}_{resolve_path.parts[-1]}" @@ -944,11 +943,9 @@ def export_data( saved_path = saved_path.with_name(exp_type) # In this scenario we use the default filename else: - if ".OpenBB_openbb_terminal" in saved_path.name: + if ".OpenBB_openbb_cli" in saved_path.name: saved_path = saved_path.with_name( - saved_path.name.replace( - ".OpenBB_openbb_terminal", "OpenBBTerminal" - ) + saved_path.name.replace(".OpenBB_openbb_cli", "OpenBBCLI") ) saved_path = saved_path.with_suffix(f".{exp_type}") diff --git a/openbb_terminal/openbb_terminal/models/settings.py b/cli/openbb_cli/models/settings.py similarity index 98% rename from openbb_terminal/openbb_terminal/models/settings.py rename to cli/openbb_cli/models/settings.py index 85dbaf2ef93..f83bca01ab3 100644 --- a/openbb_terminal/openbb_terminal/models/settings.py +++ b/cli/openbb_cli/models/settings.py @@ -3,13 +3,12 @@ from typing import Any from dotenv import dotenv_values, set_key -from pydantic import BaseModel, ConfigDict, model_validator - -from openbb_terminal.config.constants import ( +from openbb_cli.config.constants import ( ENV_FILE_PROJECT, ENV_FILE_REPOSITORY, ENV_FILE_SETTINGS, ) +from pydantic import BaseModel, ConfigDict, model_validator class Settings(BaseModel): diff --git a/openbb_terminal/openbb_terminal/session.py b/cli/openbb_cli/session.py similarity index 84% rename from openbb_terminal/openbb_terminal/session.py rename to cli/openbb_cli/session.py index a1b8be6f90f..96b63f10da9 100644 --- a/openbb_terminal/openbb_terminal/session.py +++ b/cli/openbb_cli/session.py @@ -10,10 +10,10 @@ from openbb_core.app.model.user_settings import UserSettings as User from prompt_toolkit import PromptSession from prompt_toolkit.history import FileHistory -from openbb_terminal.config.console import Console -from openbb_terminal.config.constants import HIST_FILE_PROMPT -from openbb_terminal.config.style import Style -from openbb_terminal.models.settings import Settings +from openbb_cli.config.console import Console +from openbb_cli.config.constants import HIST_FILE_PROMPT +from openbb_cli.config.style import Style +from openbb_cli.models.settings import Settings class Session(metaclass=SingletonMeta): @@ -25,7 +25,7 @@ class Session(metaclass=SingletonMeta): self._settings = Settings() self._style = Style( style=self._settings.RICH_STYLE, - directory=Path(self._obb.user.preferences.user_styles_directory), + directory=Path(self._obb.user.preferences.user_styles_directory), # type: ignore[union-attr] ) self._console = Console( settings=self._settings, style=self._style.console_style @@ -35,16 +35,16 @@ class Session(metaclass=SingletonMeta): @property def user(self) -> User: """Get platform user.""" - return self._obb.user + return self._obb.user # type: ignore[union-attr] @property def settings(self) -> Settings: - """Get terminal settings.""" + """Get CLI settings.""" return self._settings @property def style(self) -> Style: - """Get terminal style.""" + """Get CLI style.""" return self._style @property diff --git a/openbb_terminal/poetry.lock b/cli/poetry.lock similarity index 100% rename from openbb_terminal/poetry.lock rename to cli/poetry.lock diff --git a/openbb_terminal/pyproject.toml b/cli/pyproject.toml similarity index 81% rename from openbb_terminal/pyproject.toml rename to cli/pyproject.toml index 394ca5e2ea8..3ef0d94a897 100644 --- a/openbb_terminal/pyproject.toml +++ b/cli/pyproject.toml @@ -4,15 +4,15 @@ version = "1.0.0" description = "Investment Research for Everyone, Anywhere." license = "MIT" authors = ["OpenBB "] -packages = [{ include = "openbb_terminal" }] -include = ["openbb_terminal/.env"] +packages = [{ include = "openbb_cli" }] +include = ["cli/.env"] readme = "README.md" homepage = "https://openbb.co" repository = "https://github.com/OpenBB-finance/OpenBBTerminal" -documentation = "https://docs.openbb.co/sdk" +documentation = "https://docs.openbb.co/terminal" [tool.poetry.scripts] -openbb = 'openbb_terminal.cli:main' +openbb = 'openbb_cli.cli:main' [tool.poetry.dependencies] python = "^3.8.1,<3.12" diff --git a/openbb_terminal/tests/__init__.py b/cli/tests/__init__.py similarity index 100% rename from openbb_terminal/tests/__init__.py rename to cli/tests/__init__.py diff --git a/frontend-components/plotly/package.json b/frontend-components/plotly/package.json index 1d6ee039e15..383985c2685 100644 --- a/frontend-components/plotly/package.json +++ b/frontend-components/plotly/package.json @@ -6,7 +6,7 @@ "dev": "vite", "build": "vite build", "build_tsc": "tsc && vite build", - "deploy": "npm run build && mv dist/index.html ../../openbb_terminal/core/plots/plotly.html", + "deploy": "npm run build && mv dist/index.html ../../cli/openbb_cli/assets/interactive/plotly.html", "preview": "vite preview" }, "dependencies": { diff --git a/frontend-components/tables/package.json b/frontend-components/tables/package.json index 3cd7bc53225..ac4b119ca5f 100644 --- a/frontend-components/tables/package.json +++ b/frontend-components/tables/package.json @@ -7,7 +7,7 @@ "dev": "vite", "build": "vite build", "build_tsc": "tsc && vite build", - "deploy": "npm run build && mv dist/index.html ../../openbb_terminal/core/plots/table.html", + "deploy": "npm run build && mv dist/index.html ../../cli/openbb_cli/assets/interactive/table.html", "preview": "vite preview" }, "dependencies": { diff --git a/openbb_terminal/openbb_terminal/cli.py b/openbb_terminal/openbb_terminal/cli.py deleted file mode 100644 index aec05931367..00000000000 --- a/openbb_terminal/openbb_terminal/cli.py +++ /dev/null @@ -1,20 +0,0 @@ -"""OpenBB Platform CLI entry point.""" - -import sys - -from openbb_terminal.config.setup import setup_config_terminal -from openbb_terminal.controllers.terminal_controller import launch - - -def main(): - """Use the main entry point for the OpenBB Terminal CLI.""" - setup_config_terminal() - - dev = "--dev" in sys.argv[1:] - debug = "--debug" in sys.argv[1:] - - launch(dev, debug) - - -if __name__ == "__main__": - main() diff --git a/ruff.toml b/ruff.toml index b48f86e66b8..9268c3c8221 100644 --- a/ruff.toml +++ b/ruff.toml @@ -31,20 +31,20 @@ exclude = [ "website/*" = ["T201"] "*integration/*" = ["S101"] -[lint.isort] +[isort] combine-as-imports = true force-wrap-aliases = true -[lint.pylint] +[pylint] max-args = 8 max-branches = 25 max-returns = 9 max-statements = 30 -[lint.pydocstyle] +[pydocstyle] convention = "numpy" -[lint.flake8-import-conventions.aliases] +[flake8-import-conventions.aliases] "matplotlib.pyplot" = "plt" numpy = "np" pandas = "pd"