mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-12 20:31:18 +00:00
Allow reset everywhere and to execute terminal in context directly (#841)
* Allow reset everywhere and to execute terminal in context directly * minor comment fix
This commit is contained in:
@@ -13,6 +13,9 @@ from gamestonk_terminal.helper_funcs import (
|
||||
get_flair,
|
||||
parse_known_args_and_warn,
|
||||
check_positive,
|
||||
MENU_GO_BACK,
|
||||
MENU_QUIT,
|
||||
MENU_RESET,
|
||||
)
|
||||
from gamestonk_terminal.menu import session
|
||||
from gamestonk_terminal.cryptocurrency.technical_analysis import ta_controller
|
||||
@@ -52,6 +55,7 @@ class CryptoController:
|
||||
"help",
|
||||
"q",
|
||||
"quit",
|
||||
"reset",
|
||||
]
|
||||
|
||||
CHOICES_COMMAND = [
|
||||
@@ -100,6 +104,7 @@ What do you want to do?
|
||||
?/help show this menu again
|
||||
q quit this menu, and shows back to main menu
|
||||
quit quit to abandon the program
|
||||
reset reset terminal and reload configs
|
||||
"""
|
||||
help_text += (
|
||||
f"\nCoin: {self.current_coin}" if self.current_coin != "" else "\nCoin: ?"
|
||||
@@ -132,10 +137,10 @@ Note: Some of CoinGecko commands can fail. Team is working on fix.
|
||||
|
||||
Returns
|
||||
-------
|
||||
True, False or None
|
||||
False - quit the menu
|
||||
True - quit the program
|
||||
None - continue in the menu
|
||||
MENU_GO_BACK, MENU_QUIT, MENU_RESET
|
||||
MENU_GO_BACK - Show main context menu again
|
||||
MENU_QUIT - Quit terminal
|
||||
MENU_RESET - Reset terminal and go back to same previous menu
|
||||
"""
|
||||
|
||||
# Empty command
|
||||
@@ -165,11 +170,15 @@ Note: Some of CoinGecko commands can fail. Team is working on fix.
|
||||
|
||||
def call_q(self, _):
|
||||
"""Process Q command - quit the menu"""
|
||||
return False
|
||||
return MENU_GO_BACK
|
||||
|
||||
def call_quit(self, _):
|
||||
"""Process Quit command - quit the program"""
|
||||
return True
|
||||
"""Process Quit command - exit the program"""
|
||||
return MENU_QUIT
|
||||
|
||||
def call_reset(self, _):
|
||||
"""Process Reset command - exit the program"""
|
||||
return MENU_RESET
|
||||
|
||||
def call_load(self, other_args):
|
||||
"""Process load command"""
|
||||
|
||||
@@ -22,6 +22,9 @@ from gamestonk_terminal.helper_funcs import (
|
||||
get_flair,
|
||||
parse_known_args_and_warn,
|
||||
valid_date,
|
||||
MENU_GO_BACK,
|
||||
MENU_QUIT,
|
||||
MENU_RESET,
|
||||
)
|
||||
from gamestonk_terminal.menu import session
|
||||
|
||||
@@ -55,6 +58,7 @@ class EconomyController:
|
||||
"help",
|
||||
"q",
|
||||
"quit",
|
||||
"reset",
|
||||
]
|
||||
|
||||
CHOICES_COMMANDS = [
|
||||
@@ -103,6 +107,7 @@ What do you want to do?
|
||||
?/help show this menu again
|
||||
q quit this menu, and shows back to main menu
|
||||
quit quit to abandon program
|
||||
reset reset terminal and reload configs
|
||||
|
||||
CNN:
|
||||
feargreed CNN Fear and Greed Index
|
||||
@@ -135,10 +140,10 @@ FRED:
|
||||
|
||||
Returns
|
||||
-------
|
||||
True, False or None
|
||||
False - quit the menu
|
||||
True - quit the program
|
||||
None - continue in the menu
|
||||
MENU_GO_BACK, MENU_QUIT, MENU_RESET
|
||||
MENU_GO_BACK - Show main context menu again
|
||||
MENU_QUIT - Quit terminal
|
||||
MENU_RESET - Reset terminal and go back to same previous menu
|
||||
"""
|
||||
|
||||
# Empty command
|
||||
@@ -168,11 +173,15 @@ FRED:
|
||||
|
||||
def call_q(self, _):
|
||||
"""Process Q command - quit the menu"""
|
||||
return False
|
||||
return MENU_GO_BACK
|
||||
|
||||
def call_quit(self, _):
|
||||
"""Process Quit command - quit the program"""
|
||||
return True
|
||||
"""Process Quit command - exit the program"""
|
||||
return MENU_QUIT
|
||||
|
||||
def call_reset(self, _):
|
||||
"""Process Reset command - reset the program"""
|
||||
return MENU_RESET
|
||||
|
||||
def call_events(self, other_args: List[str]):
|
||||
"""Process events command"""
|
||||
|
||||
@@ -10,7 +10,13 @@ from prompt_toolkit.completion import NestedCompleter
|
||||
|
||||
from gamestonk_terminal import feature_flags as gtff
|
||||
from gamestonk_terminal.etf import screener_view, stockanalysis_view, wsj_view
|
||||
from gamestonk_terminal.helper_funcs import get_flair, parse_known_args_and_warn
|
||||
from gamestonk_terminal.helper_funcs import (
|
||||
get_flair,
|
||||
parse_known_args_and_warn,
|
||||
MENU_GO_BACK,
|
||||
MENU_QUIT,
|
||||
MENU_RESET,
|
||||
)
|
||||
from gamestonk_terminal.menu import session
|
||||
|
||||
|
||||
@@ -23,6 +29,7 @@ class ETFController:
|
||||
"help",
|
||||
"q",
|
||||
"quit",
|
||||
"reset",
|
||||
]
|
||||
|
||||
CHOICES_COMMANDS = [
|
||||
@@ -53,6 +60,7 @@ What do you want to do?
|
||||
?/help show this menu again
|
||||
q quit this menu, and shows back to main menu
|
||||
quit quit to abandon the program
|
||||
reset reset terminal and reload configs
|
||||
|
||||
StockAnalysis.com:
|
||||
search search ETFs matching name (i.e. BlackRock or Invesco)
|
||||
@@ -73,10 +81,10 @@ Wall St. Journal:
|
||||
|
||||
Returns
|
||||
-------
|
||||
True, False or None
|
||||
False - quit the menu
|
||||
True - quit the program
|
||||
None - continue in the menu
|
||||
MENU_GO_BACK, MENU_QUIT, MENU_RESET
|
||||
MENU_GO_BACK - Show main context menu again
|
||||
MENU_QUIT - Quit terminal
|
||||
MENU_RESET - Reset terminal and go back to same previous menu
|
||||
"""
|
||||
|
||||
# Empty command
|
||||
@@ -106,11 +114,15 @@ Wall St. Journal:
|
||||
|
||||
def call_q(self, _):
|
||||
"""Process Q command - quit the menu"""
|
||||
return False
|
||||
return MENU_GO_BACK
|
||||
|
||||
def call_quit(self, _):
|
||||
"""Process Quit command - quit the program"""
|
||||
return True
|
||||
"""Process Quit command - exit the program"""
|
||||
return MENU_QUIT
|
||||
|
||||
def call_reset(self, _):
|
||||
"""Process Reset command - reset the program"""
|
||||
return MENU_RESET
|
||||
|
||||
def call_search(self, other_args: List[str]):
|
||||
"""Process search command"""
|
||||
|
||||
@@ -11,7 +11,12 @@ from gamestonk_terminal.forex import fx_view
|
||||
from gamestonk_terminal.forex.behavioural_analysis import ba_controller
|
||||
|
||||
# from gamestonk_terminal.forex.exploratory_data_analysis import eda_controller
|
||||
from gamestonk_terminal.helper_funcs import get_flair
|
||||
from gamestonk_terminal.helper_funcs import (
|
||||
get_flair,
|
||||
MENU_GO_BACK,
|
||||
MENU_QUIT,
|
||||
MENU_RESET,
|
||||
)
|
||||
from gamestonk_terminal.menu import session
|
||||
|
||||
# from gamestonk_terminal.stocks.due_diligence import news_view, reddit_view
|
||||
@@ -29,6 +34,7 @@ class ForexController:
|
||||
"help",
|
||||
"q",
|
||||
"quit",
|
||||
"reset",
|
||||
]
|
||||
|
||||
CHOICES_COMMANDS = [
|
||||
@@ -74,6 +80,7 @@ class ForexController:
|
||||
print(" ?/help show this menu again")
|
||||
print(" q quit this menu and goes back to main menu")
|
||||
print(" quit quit to abandon program")
|
||||
print(" reset reset terminal and reload configs")
|
||||
print("")
|
||||
print(" summary shows account summary")
|
||||
print(" calendar show calendar")
|
||||
@@ -98,9 +105,6 @@ class ForexController:
|
||||
" reddit search reddit for posts about the loaded instrument"
|
||||
)
|
||||
print("")
|
||||
# print(
|
||||
# "> eda exploratory data analysis, e.g.: decompose, cusum, residuals analysis"
|
||||
# )
|
||||
print(
|
||||
"> ba behavioural analysis, from: reddit, stocktwits, twitter, google"
|
||||
)
|
||||
@@ -111,10 +115,10 @@ class ForexController:
|
||||
|
||||
Returns
|
||||
-------
|
||||
True, False, or None
|
||||
False - quit the menu
|
||||
True - quit the program
|
||||
None - continue in the menu
|
||||
MENU_GO_BACK, MENU_QUIT, MENU_RESET
|
||||
MENU_GO_BACK - Show main context menu again
|
||||
MENU_QUIT - Quit terminal
|
||||
MENU_RESET - Reset terminal and go back to same previous menu
|
||||
"""
|
||||
|
||||
# Empty command
|
||||
@@ -144,11 +148,15 @@ class ForexController:
|
||||
|
||||
def call_q(self, _):
|
||||
"""Process Q command - quit the menu"""
|
||||
return False
|
||||
return MENU_GO_BACK
|
||||
|
||||
def call_quit(self, _):
|
||||
"""Process Quit command - exit the program"""
|
||||
return True
|
||||
return MENU_QUIT
|
||||
|
||||
def call_reset(self, _):
|
||||
"""Process Reset command - reset the program"""
|
||||
return MENU_RESET
|
||||
|
||||
def call_price(self, other_args):
|
||||
"""Process Price Command"""
|
||||
|
||||
@@ -31,6 +31,10 @@ EXPORT_ONLY_RAW_DATA_ALLOWED = 1
|
||||
EXPORT_ONLY_FIGURES_ALLOWED = 2
|
||||
EXPORT_BOTH_RAW_DATA_AND_FIGURES = 3
|
||||
|
||||
MENU_GO_BACK = 0
|
||||
MENU_QUIT = 1
|
||||
MENU_RESET = 2
|
||||
|
||||
|
||||
def check_int_range(mini: int, maxi: int):
|
||||
"""Checks if argparse argument is an int between 2 values.
|
||||
|
||||
@@ -17,6 +17,9 @@ from gamestonk_terminal.helper_funcs import (
|
||||
check_positive,
|
||||
get_flair,
|
||||
parse_known_args_and_warn,
|
||||
MENU_GO_BACK,
|
||||
MENU_QUIT,
|
||||
MENU_RESET,
|
||||
)
|
||||
from gamestonk_terminal.menu import session
|
||||
from gamestonk_terminal.options import (
|
||||
@@ -42,6 +45,7 @@ class OptionsController:
|
||||
"help",
|
||||
"q",
|
||||
"quit",
|
||||
"reset",
|
||||
]
|
||||
|
||||
CHOICES_MENUS = [
|
||||
@@ -111,6 +115,7 @@ What do you want to do?
|
||||
?/help show this menu again
|
||||
q quit this menu, and shows back to main menu
|
||||
quit quit to abandon program
|
||||
reset reset terminal and reload configs
|
||||
|
||||
"""
|
||||
help_text += ">> stocks go into stocks context"
|
||||
@@ -149,10 +154,10 @@ Current Expiry: {self.selected_date or None}
|
||||
|
||||
Returns
|
||||
-------
|
||||
True, False or None
|
||||
False - quit the menu
|
||||
True - quit the program
|
||||
None - continue in the menu
|
||||
MENU_GO_BACK, MENU_QUIT, MENU_RESET
|
||||
MENU_GO_BACK - Show main context menu again
|
||||
MENU_QUIT - Quit terminal
|
||||
MENU_RESET - Reset terminal and go back to same previous menu
|
||||
"""
|
||||
|
||||
# Empty command
|
||||
@@ -181,12 +186,16 @@ Current Expiry: {self.selected_date or None}
|
||||
self.print_help()
|
||||
|
||||
def call_q(self, _):
|
||||
"""Process Q command - quit the menu."""
|
||||
return False
|
||||
"""Process Q command - quit the menu"""
|
||||
return MENU_GO_BACK
|
||||
|
||||
def call_quit(self, _):
|
||||
"""Process Quit command - quit the program."""
|
||||
return True
|
||||
"""Process Quit command - exit the program"""
|
||||
return MENU_QUIT
|
||||
|
||||
def call_reset(self, _):
|
||||
"""Process Reset command - reset the program"""
|
||||
return MENU_RESET
|
||||
|
||||
def call_calc(self, other_args: List[str]):
|
||||
"""Process calc command"""
|
||||
|
||||
@@ -7,7 +7,12 @@ import os
|
||||
from prompt_toolkit.completion import NestedCompleter
|
||||
|
||||
from gamestonk_terminal import feature_flags as gtff
|
||||
from gamestonk_terminal.helper_funcs import get_flair
|
||||
from gamestonk_terminal.helper_funcs import (
|
||||
get_flair,
|
||||
MENU_GO_BACK,
|
||||
MENU_QUIT,
|
||||
MENU_RESET,
|
||||
)
|
||||
from gamestonk_terminal.menu import session
|
||||
from gamestonk_terminal.portfolio.brokers import bro_controller
|
||||
from gamestonk_terminal.portfolio.portfolio_analysis import pa_controller
|
||||
@@ -25,6 +30,7 @@ class PortfolioController:
|
||||
"help",
|
||||
"q",
|
||||
"quit",
|
||||
"reset",
|
||||
]
|
||||
|
||||
CHOICES_MENUS = [
|
||||
@@ -56,6 +62,7 @@ What do you want to do?
|
||||
?/help show this menu again
|
||||
q quit this menu, and shows back to main menu
|
||||
quit quit to abandon the program
|
||||
reset reset terminal and reload configs
|
||||
|
||||
> bro brokers holdings, \t\t supports: robinhood, alpaca, ally, degiro
|
||||
> pa portfolio analysis, \t\t analyses your custom portfolio
|
||||
@@ -68,10 +75,10 @@ What do you want to do?
|
||||
|
||||
Returns
|
||||
-------
|
||||
True, False, or None
|
||||
False - quit the menu
|
||||
True - quit the program
|
||||
None - continue in the menu
|
||||
MENU_GO_BACK, MENU_QUIT, MENU_RESET
|
||||
MENU_GO_BACK - Show main context menu again
|
||||
MENU_QUIT - Quit terminal
|
||||
MENU_RESET - Reset terminal and go back to same previous menu
|
||||
"""
|
||||
|
||||
# Empty command
|
||||
@@ -101,11 +108,15 @@ What do you want to do?
|
||||
|
||||
def call_q(self, _):
|
||||
"""Process Q command - quit the menu"""
|
||||
return False
|
||||
return MENU_GO_BACK
|
||||
|
||||
def call_quit(self, _):
|
||||
"""Process Quit command - exit the program"""
|
||||
return True
|
||||
return MENU_QUIT
|
||||
|
||||
def call_reset(self, _):
|
||||
"""Process Reset command - reset the program"""
|
||||
return MENU_RESET
|
||||
|
||||
# MENUS
|
||||
def call_bro(self, _):
|
||||
|
||||
@@ -8,7 +8,12 @@ import webbrowser
|
||||
from prompt_toolkit.completion import NestedCompleter
|
||||
|
||||
from gamestonk_terminal import feature_flags as gtff
|
||||
from gamestonk_terminal.helper_funcs import get_flair
|
||||
from gamestonk_terminal.helper_funcs import (
|
||||
get_flair,
|
||||
MENU_GO_BACK,
|
||||
MENU_QUIT,
|
||||
MENU_RESET,
|
||||
)
|
||||
from gamestonk_terminal.menu import session
|
||||
|
||||
|
||||
@@ -22,6 +27,7 @@ class ResourceCollectionController:
|
||||
"help",
|
||||
"q",
|
||||
"quit",
|
||||
"reset",
|
||||
]
|
||||
|
||||
CHOICES_COMMANDS = [
|
||||
@@ -55,6 +61,7 @@ What do you want to do?
|
||||
?/help show this menu again
|
||||
q quit this menu, and shows back to main menu
|
||||
quit quit to abandon program
|
||||
reset reset terminal and reload configs
|
||||
|
||||
hfletters hedge fund letters or reports
|
||||
arxiv open-access archive for academic articles
|
||||
@@ -71,10 +78,10 @@ What do you want to do?
|
||||
|
||||
Returns
|
||||
-------
|
||||
True, False or None
|
||||
False - quit the menu
|
||||
True - quit the program
|
||||
None - continue in the menu
|
||||
MENU_GO_BACK, MENU_QUIT, MENU_RESET
|
||||
MENU_GO_BACK - Show main context menu again
|
||||
MENU_QUIT - Quit terminal
|
||||
MENU_RESET - Reset terminal and go back to same previous menu
|
||||
"""
|
||||
|
||||
# Empty command
|
||||
@@ -107,11 +114,15 @@ What do you want to do?
|
||||
|
||||
def call_q(self, _):
|
||||
"""Process Q command - quit the menu"""
|
||||
return False
|
||||
return MENU_GO_BACK
|
||||
|
||||
def call_quit(self, _):
|
||||
"""Process Quit command - quit the program"""
|
||||
return True
|
||||
"""Process Quit command - exit the program"""
|
||||
return MENU_QUIT
|
||||
|
||||
def call_reset(self, _):
|
||||
"""Process Reset command - reset the program"""
|
||||
return MENU_RESET
|
||||
|
||||
def call_hfletters(self, _):
|
||||
"""Process hfletters command"""
|
||||
|
||||
@@ -33,7 +33,12 @@ from gamestonk_terminal.stocks.research import res_controller
|
||||
from gamestonk_terminal.stocks.screener import screener_controller
|
||||
from gamestonk_terminal.stocks.stocks_helper import candle, load, quote
|
||||
from gamestonk_terminal.stocks.technical_analysis import ta_controller
|
||||
from gamestonk_terminal.helper_funcs import valid_date
|
||||
from gamestonk_terminal.helper_funcs import (
|
||||
valid_date,
|
||||
MENU_GO_BACK,
|
||||
MENU_QUIT,
|
||||
MENU_RESET,
|
||||
)
|
||||
from gamestonk_terminal.common.quantitative_analysis import qa_view
|
||||
|
||||
# pylint: disable=R1710
|
||||
@@ -51,6 +56,7 @@ class StocksController:
|
||||
"help",
|
||||
"q",
|
||||
"quit",
|
||||
"reset",
|
||||
]
|
||||
|
||||
CHOICES_COMMANDS = [
|
||||
@@ -109,7 +115,6 @@ class StocksController:
|
||||
dim_if_no_ticker = Style.DIM if not self.ticker else ""
|
||||
reset_style_if_no_ticker = Style.RESET_ALL if not self.ticker else ""
|
||||
help_text = f"""
|
||||
|
||||
>> STOCKS <<
|
||||
|
||||
What do you want to do?
|
||||
@@ -117,6 +122,7 @@ What do you want to do?
|
||||
?/help show this menu again
|
||||
q quit this menu, and shows back to main menu
|
||||
quit quit to abandon the program
|
||||
reset reset terminal and reload configs
|
||||
|
||||
load load a specific stock ticker for analysis
|
||||
|
||||
@@ -152,10 +158,10 @@ Market {('CLOSED', 'OPEN')[b_is_stock_market_open()]}
|
||||
|
||||
Returns
|
||||
-------
|
||||
True, False, or None
|
||||
False - quit the menu
|
||||
True - quit the program
|
||||
None - continue in the menu
|
||||
MENU_GO_BACK, MENU_QUIT, MENU_RESET
|
||||
MENU_GO_BACK - Show main context menu again
|
||||
MENU_QUIT - Quit terminal
|
||||
MENU_RESET - Reset terminal and go back to same previous menu
|
||||
"""
|
||||
|
||||
# Empty command
|
||||
@@ -185,11 +191,15 @@ Market {('CLOSED', 'OPEN')[b_is_stock_market_open()]}
|
||||
|
||||
def call_q(self, _):
|
||||
"""Process Q command - quit the menu"""
|
||||
return False
|
||||
return MENU_GO_BACK
|
||||
|
||||
def call_quit(self, _):
|
||||
"""Process Quit command - exit the program"""
|
||||
return True
|
||||
return MENU_QUIT
|
||||
|
||||
def call_reset(self, _):
|
||||
"""Process Reset command - reset the program"""
|
||||
return MENU_RESET
|
||||
|
||||
# COMMANDS
|
||||
def call_load(self, other_args: List[str]):
|
||||
|
||||
@@ -397,16 +397,16 @@ def bootup():
|
||||
print("")
|
||||
|
||||
|
||||
def reset():
|
||||
def reset(menu_prior_to_reset=""):
|
||||
"""Resets the terminal. Allows for checking code or keys without quitting"""
|
||||
print("resetting...")
|
||||
plt.close("all")
|
||||
completed_process = subprocess.run("python terminal.py", shell=True, check=False)
|
||||
|
||||
arg = f" {menu_prior_to_reset}" if menu_prior_to_reset else ""
|
||||
completed_process = subprocess.run(
|
||||
f"{sys.executable} terminal.py{arg}", shell=True, check=False
|
||||
)
|
||||
if completed_process.returncode != 0:
|
||||
completed_process = subprocess.run(
|
||||
"python3 terminal.py", shell=True, check=False
|
||||
)
|
||||
if completed_process.returncode != 0:
|
||||
print("Unfortunately, resetting wasn't possible!\n")
|
||||
print("Unfortunately, resetting wasn't possible!\n")
|
||||
|
||||
return completed_process.returncode
|
||||
|
||||
64
terminal.py
64
terminal.py
@@ -10,7 +10,12 @@ from prompt_toolkit.completion import NestedCompleter
|
||||
|
||||
from gamestonk_terminal import config_terminal
|
||||
from gamestonk_terminal import feature_flags as gtff
|
||||
from gamestonk_terminal.helper_funcs import get_flair
|
||||
from gamestonk_terminal.helper_funcs import (
|
||||
get_flair,
|
||||
MENU_RESET,
|
||||
MENU_GO_BACK,
|
||||
MENU_QUIT,
|
||||
)
|
||||
from gamestonk_terminal.menu import session
|
||||
from gamestonk_terminal.terminal_helper import (
|
||||
about_us,
|
||||
@@ -233,41 +238,43 @@ What do you want to do?
|
||||
return self.call_portfolio(_)
|
||||
|
||||
|
||||
def terminal():
|
||||
def terminal(menu_prior_to_reset=""):
|
||||
"""Terminal Menu"""
|
||||
|
||||
bootup()
|
||||
process_input = False
|
||||
t_controller = TerminalController()
|
||||
|
||||
if config_terminal.DEFAULT_CONTEXT:
|
||||
if config_terminal.DEFAULT_CONTEXT in t_controller.CHOICES_MENUS:
|
||||
if config_terminal.DEFAULT_CONTEXT or menu_prior_to_reset:
|
||||
if (
|
||||
config_terminal.DEFAULT_CONTEXT in t_controller.CHOICES_MENUS
|
||||
or menu_prior_to_reset in t_controller.CHOICES_MENUS
|
||||
):
|
||||
try:
|
||||
print("")
|
||||
process_input = t_controller.switch(
|
||||
config_terminal.DEFAULT_CONTEXT.lower()
|
||||
menu_prior_to_reset or config_terminal.DEFAULT_CONTEXT.lower()
|
||||
)
|
||||
# Check if the user wants to reset application
|
||||
if process_input == MENU_RESET:
|
||||
ret_code = reset(menu_prior_to_reset)
|
||||
if ret_code != 0:
|
||||
print_goodbye()
|
||||
|
||||
except SystemExit:
|
||||
print("")
|
||||
else:
|
||||
print("\nInvalid DEFAULT_CONTEXT config selected!", "\n")
|
||||
|
||||
if not process_input:
|
||||
if process_input != MENU_QUIT:
|
||||
t_controller.print_help()
|
||||
parsed_stdin = False
|
||||
|
||||
while True:
|
||||
if gtff.ENABLE_QUICK_EXIT:
|
||||
print("Quick exit enabled")
|
||||
break
|
||||
|
||||
# Get input command from stdin or user
|
||||
if not parsed_stdin and len(sys.argv) > 1:
|
||||
an_input = " ".join(sys.argv[1:])
|
||||
print(f"{get_flair()}> {an_input}")
|
||||
parsed_stdin = True
|
||||
|
||||
elif session and gtff.USE_PROMPT_TOOLKIT:
|
||||
if session and gtff.USE_PROMPT_TOOLKIT:
|
||||
an_input = session.prompt(
|
||||
f"{get_flair()}> ", completer=t_controller.completer
|
||||
)
|
||||
@@ -283,16 +290,14 @@ def terminal():
|
||||
# Process list of commands selected by user
|
||||
try:
|
||||
process_input = t_controller.switch(an_input)
|
||||
# None - Keep loop
|
||||
# True - Quit or Reset based on flag
|
||||
# False - Keep loop and show help menu
|
||||
|
||||
if process_input is not None:
|
||||
# Quit terminal
|
||||
if process_input:
|
||||
break
|
||||
# MENU_GO_BACK - Show main context menu again
|
||||
# MENU_QUIT - Quit terminal
|
||||
# MENU_RESET - Reset terminal and go back to same previous menu
|
||||
|
||||
if process_input == MENU_GO_BACK:
|
||||
t_controller.print_help()
|
||||
else:
|
||||
break
|
||||
|
||||
except SystemExit:
|
||||
print("The command selected doesn't exist\n")
|
||||
@@ -300,13 +305,22 @@ def terminal():
|
||||
|
||||
if not gtff.ENABLE_QUICK_EXIT:
|
||||
# Check if the user wants to reset application
|
||||
if an_input == "reset" or t_controller.update_succcess:
|
||||
ret_code = reset()
|
||||
if (
|
||||
an_input == "reset"
|
||||
or t_controller.update_succcess
|
||||
or process_input == MENU_RESET
|
||||
):
|
||||
ret_code = reset(an_input if an_input != "reset" else "")
|
||||
if ret_code != 0:
|
||||
print_goodbye()
|
||||
else:
|
||||
print_goodbye()
|
||||
else:
|
||||
print_goodbye()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
terminal()
|
||||
if len(sys.argv) > 1:
|
||||
terminal(sys.argv[1])
|
||||
else:
|
||||
terminal()
|
||||
|
||||
Reference in New Issue
Block a user