mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-27 04:31:13 +00:00
[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
This commit is contained in:
48
.github/workflows/docker-build.yml
vendored
48
.github/workflows/docker-build.yml
vendored
@@ -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')
|
||||
6
.gitignore
vendored
6
.gitignore
vendored
@@ -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/*
|
||||
|
||||
1
.pre-commit-config.yaml
vendored
1
.pre-commit-config.yaml
vendored
@@ -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
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
@@ -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
|
||||
20
cli/openbb_cli/cli.py
Normal file
20
cli/openbb_cli/cli.py
Normal file
@@ -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()
|
||||
@@ -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,
|
||||
)
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -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)
|
||||
@@ -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()
|
||||
|
||||
@@ -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(
|
||||
'<style bg="ansiblack" fg="ansiwhite">[h]</style> help menu '
|
||||
'<style bg="ansiblack" fg="ansiwhite">[q]</style> return to previous menu '
|
||||
'<style bg="ansiblack" fg="ansiwhite">[e]</style> exit terminal '
|
||||
'<style bg="ansiblack" fg="ansiwhite">[e]</style> exit the program '
|
||||
'<style bg="ansiblack" fg="ansiwhite">[cmd -h]</style> '
|
||||
"see usage and available options "
|
||||
f'<style bg="ansiblack" fg="ansiwhite">[about (cmd/menu)]</style> '
|
||||
@@ -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:
|
||||
@@ -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`.
|
||||
|
||||
@@ -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(
|
||||
'<style bg="ansiblack" fg="ansiwhite">[h]</style> help menu '
|
||||
'<style bg="ansiblack" fg="ansiwhite">[q]</style> return to previous menu '
|
||||
'<style bg="ansiblack" fg="ansiwhite">[e]</style> exit terminal '
|
||||
'<style bg="ansiblack" fg="ansiwhite">[e]</style> exit the program '
|
||||
'<style bg="ansiblack" fg="ansiwhite">[cmd -h]</style> '
|
||||
"see usage and available options "
|
||||
'<style bg="ansiblack" fg="ansiwhite">[about (cmd/menu)]</style> '
|
||||
@@ -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="")
|
||||
@@ -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:
|
||||
@@ -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"]}
|
||||
@@ -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:
|
||||
@@ -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
|
||||
@@ -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}")
|
||||
|
||||
@@ -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):
|
||||
@@ -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
|
||||
0
openbb_terminal/poetry.lock → cli/poetry.lock
generated
vendored
0
openbb_terminal/poetry.lock → cli/poetry.lock
generated
vendored
@@ -4,15 +4,15 @@ version = "1.0.0"
|
||||
description = "Investment Research for Everyone, Anywhere."
|
||||
license = "MIT"
|
||||
authors = ["OpenBB <hello@openbb.co>"]
|
||||
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"
|
||||
2
frontend-components/plotly/package.json
vendored
2
frontend-components/plotly/package.json
vendored
@@ -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": {
|
||||
|
||||
2
frontend-components/tables/package.json
vendored
2
frontend-components/tables/package.json
vendored
@@ -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": {
|
||||
|
||||
@@ -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()
|
||||
8
ruff.toml
vendored
8
ruff.toml
vendored
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user