Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion icli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ async def initcli():
# patch entire application with prompt-toolkit-compatible stdout
with patch_stdout(raw=True):
try:
await app.runall()
if len(sys.argv) > 1:
# just add quotes to the first arg to get 1 parameter
cmds = sys.argv[1]
else:
cmds = None
await app.runall(cmds)
except (SystemExit, EOFError):
# known-good exit condition
pass
Expand Down
40 changes: 33 additions & 7 deletions icli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3019,19 +3019,45 @@ def buildRunnablesFromCommandRequest(self, text1):

return runnables

async def runall(self):
async def runall(self, cmds=None):
logger.info(
"Using ib_async version: {} :: {}",
ib_async.version.__version__,
ib_async.version.__version_info__,
)
await self.prepare()
while not self.exiting:
try:
await self.dorepl()
except:
logger.exception("Uncaught exception in repl? Restarting...")
continue

if cmds is not None:
# just execute the given args as as command(s) and exit

# 'runnables' is the list of all commands to run after we collect them
runnables = self.buildRunnablesFromCommandRequest(cmds)

# if no commands, just draw the prompt again
if not runnables:
return

if len(runnables) == 1:
# if only one command, don't run with an extra Timer() report like we do below
# with multiple commands (individual commands always report their individual timing)
await runnables[0]
else:
# only show the "All commands" timer if we have multiple commands to run
with Timer("All commands"):
for run in runnables:
try:
# run a COLLECTIVE COMMAND GROUP we previously created
await run
except:
logger.exception("[{}] Runnable failed?", run)
self.exiting = True
else:
while not self.exiting:
try:
await self.dorepl()
except:
logger.exception("Uncaught exception in repl? Restarting...")
continue

async def prepare(self):
# Setup...
Expand Down
2 changes: 1 addition & 1 deletion icli/lang.py
Original file line number Diff line number Diff line change
Expand Up @@ -3359,7 +3359,7 @@ def populateSymbolDetails(target):
if df.empty:
logger.info(
"{}No open orders exist for client id {}!",
f"[{", ".join(sorted(self.symbols))}] " if self.symbols else "",
f"[{', '.join(sorted(self.symbols))}] " if self.symbols else "",
ICLI_CLIENT_ID,
)
return
Expand Down