mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-12-01 13:44:16 +00:00
Tests with prompt-toolkit
This commit is contained in:
@@ -11,6 +11,9 @@ from gamestonk_terminal.discovery import unusual_whales_api
|
||||
|
||||
from gamestonk_terminal.helper_funcs import get_flair
|
||||
|
||||
from gamestonk_terminal.menu import session
|
||||
from prompt_toolkit.completion import WordCompleter
|
||||
|
||||
|
||||
def print_discovery():
|
||||
""" Print help """
|
||||
@@ -42,33 +45,35 @@ def disc_menu():
|
||||
|
||||
# Add list of arguments that the discovery parser accepts
|
||||
disc_parser = argparse.ArgumentParser(prog="discovery", add_help=False)
|
||||
disc_parser.add_argument(
|
||||
"cmd",
|
||||
choices=[
|
||||
"help",
|
||||
"q",
|
||||
"quit",
|
||||
"map",
|
||||
"sectors",
|
||||
"gainers",
|
||||
"spacs",
|
||||
"orders",
|
||||
"spachero",
|
||||
"high_short",
|
||||
"low_float",
|
||||
"up_earnings",
|
||||
"simply_wallst",
|
||||
"uwhales",
|
||||
"mill",
|
||||
],
|
||||
)
|
||||
choices = [
|
||||
"help",
|
||||
"q",
|
||||
"quit",
|
||||
"map",
|
||||
"sectors",
|
||||
"gainers",
|
||||
"spacs",
|
||||
"orders",
|
||||
"spachero",
|
||||
"high_short",
|
||||
"low_float",
|
||||
"up_earnings",
|
||||
"simply_wallst",
|
||||
"uwhales",
|
||||
"mill",
|
||||
]
|
||||
disc_parser.add_argument("cmd", choices=choices)
|
||||
word_completer = WordCompleter(choices)
|
||||
|
||||
print_discovery()
|
||||
|
||||
# Loop forever and ever
|
||||
while True:
|
||||
# Get input command from user
|
||||
as_input = input(f"{get_flair()} (disc)> ")
|
||||
as_input = session.prompt(
|
||||
f"{get_flair()} (disc)> ",
|
||||
completer=word_completer,
|
||||
)
|
||||
|
||||
# Parse fundamental analysis command of the list of possible commands
|
||||
try:
|
||||
|
||||
7
gamestonk_terminal/menu.py
Normal file
7
gamestonk_terminal/menu.py
Normal file
@@ -0,0 +1,7 @@
|
||||
import os
|
||||
|
||||
from prompt_toolkit import PromptSession
|
||||
from prompt_toolkit.history import FileHistory
|
||||
|
||||
history_file = os.path.join(os.path.expanduser("~"), ".gamestonk_terminal.his")
|
||||
session = PromptSession(history=FileHistory(history_file))
|
||||
@@ -156,3 +156,4 @@ wrapt==1.12.1; python_version >= "3.6" and python_full_version < "3.0.0" or pyth
|
||||
yarl==1.6.3; python_version >= "3.6"
|
||||
yfinance==0.1.55
|
||||
zipp==3.4.1; python_version < "3.8" and python_version >= "3.6"
|
||||
prompt-toolkit==3.0.16; python_version >= "3.6"
|
||||
|
||||
@@ -133,3 +133,4 @@ wrapt==1.12.1; python_version >= "3.6" and python_full_version < "3.0.0" or pyth
|
||||
yarl==1.6.3; python_version >= "3.6"
|
||||
yfinance==0.1.55
|
||||
zipp==3.4.0; python_version >= "3.6" and python_full_version < "3.0.0" and python_version < "3.8" or python_full_version >= "3.2.0" and python_version >= "3.6" and python_version < "3.8"
|
||||
prompt-toolkit==3.0.16; python_version >= "3.6"
|
||||
|
||||
@@ -133,3 +133,4 @@ wrapt==1.12.1; python_version >= "3.6" and python_full_version < "3.0.0" or pyth
|
||||
yarl==1.6.3; python_version >= "3.6"
|
||||
yfinance==0.1.55
|
||||
zipp==3.4.0; python_version >= "3.6" and python_full_version < "3.0.0" and python_version < "3.8" or python_full_version >= "3.2.0" and python_version >= "3.6" and python_version < "3.8"
|
||||
prompt-toolkit==3.0.16; python_version >= "3.6"
|
||||
|
||||
@@ -90,3 +90,4 @@ websocket-client==0.58.0; python_version >= "3.6" and python_full_version < "3.0
|
||||
yarl==1.6.3; python_version >= "3.6"
|
||||
yfinance==0.1.55
|
||||
zipp==3.4.1; python_version < "3.8" and python_version >= "3.6"
|
||||
prompt-toolkit==3.0.16; python_version >= "3.6"
|
||||
|
||||
47
terminal.py
47
terminal.py
@@ -15,6 +15,9 @@ from gamestonk_terminal.sentiment import sen_menu as sm
|
||||
from gamestonk_terminal.papermill import papermill_menu as mill
|
||||
from gamestonk_terminal import res_menu as rm
|
||||
from gamestonk_terminal import config_terminal as cfg
|
||||
from gamestonk_terminal.menu import session
|
||||
from prompt_toolkit.completion import WordCompleter
|
||||
|
||||
|
||||
# import warnings
|
||||
# warnings.simplefilter("always")
|
||||
@@ -42,26 +45,25 @@ def main():
|
||||
|
||||
# Add list of arguments that the main parser accepts
|
||||
menu_parser = argparse.ArgumentParser(prog="gamestonk_terminal", add_help=False)
|
||||
menu_parser.add_argument(
|
||||
"opt",
|
||||
choices=[
|
||||
"help",
|
||||
"quit",
|
||||
"q",
|
||||
"clear",
|
||||
"load",
|
||||
"view",
|
||||
"export",
|
||||
"disc",
|
||||
"mill",
|
||||
"sen",
|
||||
"res",
|
||||
"fa",
|
||||
"ta",
|
||||
"dd",
|
||||
"pred",
|
||||
],
|
||||
)
|
||||
choices = [
|
||||
"help",
|
||||
"quit",
|
||||
"q",
|
||||
"clear",
|
||||
"load",
|
||||
"view",
|
||||
"export",
|
||||
"disc",
|
||||
"mill",
|
||||
"sen",
|
||||
"res",
|
||||
"fa",
|
||||
"ta",
|
||||
"dd",
|
||||
"pred",
|
||||
]
|
||||
menu_parser.add_argument("opt", choices=choices)
|
||||
word_completer = WordCompleter(choices)
|
||||
|
||||
# Print first welcome message and help
|
||||
print("")
|
||||
@@ -77,7 +79,10 @@ def main():
|
||||
should_print_help = False
|
||||
|
||||
# Get input command from user
|
||||
as_input = input(f"{get_flair()}> ")
|
||||
as_input = session.prompt(
|
||||
f"{get_flair()}> ",
|
||||
completer=word_completer,
|
||||
)
|
||||
|
||||
# Is command empty
|
||||
if not as_input:
|
||||
|
||||
Reference in New Issue
Block a user