Hi Jon,
Good question. The short answer is "no", but there are workarounds.
I often use bespoke scripts that I customize by hand. For example, here is a script that I use to import multiple files:
@language python
"""Recursively import all python files in a directory and clean the result."""
@tabwidth -4 # For a better match.
g.cls()
dir_ = r'<<path to a folder>> # <--- customize as needed
c.recursiveImport(
dir_=dir_,
kind = '@clean', # '@auto', '@clean', '@nosent','@file',
recursive = True,
safe_at_file = True,
theTypes = ['.py',],
verbose = True,
)
if 1:
last = c.lastTopLevel()
last.expand()
if last.hasChildren():
last.firstChild().expand()
c.redraw(last)
print('Done')
I will typically execute this script several times, so it would be less convenient to "generalize" it by asking for a path.
Other workarounds
It's almost always simplest to write your own scripts. But if you really want to write a general command, Leo provides ways to do that.
The big hint: look for code in Leo's codebase that does something similar to what you want. For example, Leo's find commands prompt for one or more arguments. The code isn't pretty. find.find-next and find.change-all show how to set up the required state machines.
The node c.interactive* in leoCommands.py contains helpers that set up state machines.
Summary
Writing bespoke scripts is almost always the simplest solution.
Other solutions involve state machines. I would only consider such approaches in extraordinary circumstances.
HTH.
Edward