From 032a11cada11f5b6465cf8cc69e1923e95a502f0 Mon Sep 17 00:00:00 2001 From: Aaron Cutright Date: Thu, 18 Mar 2021 20:30:31 -0400 Subject: [PATCH] Accept stdin args for terminal.py --- terminal.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/terminal.py b/terminal.py index 7dcf72edb9c..e5faa38c273 100644 --- a/terminal.py +++ b/terminal.py @@ -82,6 +82,7 @@ def main(): # Print first welcome message and help print("\nWelcome to Gamestonk Terminal 🚀\n") should_print_help = True + parsed_stdin = False # Loop forever and ever while True: @@ -90,8 +91,12 @@ def main(): print_help(s_ticker, s_start, s_interval, b_is_stock_market_open()) should_print_help = False - # Get input command from user - if session and gtff.USE_PROMPT_TOOLKIT: + # Get input command from stdin or user + if not parsed_stdin and len(sys.argv) > 1: + as_input = " ".join(sys.argv[1:]) + parsed_stdin = True + print(f"{get_flair()}> {as_input}") + elif session and gtff.USE_PROMPT_TOOLKIT: as_input = session.prompt(f"{get_flair()}> ", completer=completer) else: as_input = input(f"{get_flair()}> ")