a REPL for development #2290
Replies: 4 comments 3 replies
-
Using an rlwrap subprocess is a clever idea, I dig it! I also found myself often wanting a REPL which led to the vdrepl plugin. That's a different approach with different assumptions/dependencies though. I haven't touched it because it still works, but it could probably use a cleanup pass. Your method seems to work smoothly out of the box for me 💪 . Regarding the import subprocess
import pprint
def rlwrap_repl():
with SuspendCurses():
pp = pprint.PrettyPrinter(indent=4).pprint
while True:
try:
source = subprocess.run(['rlwrap','--one-shot','--substitute-prompt',">>> ",'cat'], text=True, capture_output=True).stdout
if not source:
break
print(eval(source))
except (EOFError, KeyboardInterrupt):
break
except Exception as e:
print(e)
continue
BaseSheet.addCommand('', 'REPL', 'rlwrap_repl()') |
Beta Was this translation helpful? Give feedback.
-
Since multiple people want a REPL for VisiData like this, what do y'all think about combining the best ideas from @justin2004's code and @ajkerrigan's vdrepl plugin and pulling them into the vd repo formally? |
Beta Was this translation helpful? Give feedback.
-
BTW did y'all know about the |
Beta Was this translation helpful? Give feedback.
-
@saulpw what happened with this feature:? It looks like it did not get added this year. I can add a feature request to track this, if that would help any. |
Beta Was this translation helpful? Give feedback.
-
Hi all,
I am making some new commands and I kept finding myself doing this:
that is, using the status window as a console log to see what functions/attributes objects have.
But that requires that I save
.visidatarc
and re-runvd
.I really wanted a REPL for this so I put this into my
.visidatarc
.You'll first want to
apt-get install rlwrap
and if you like vim I would put this in~/.inputrc
:Now I can inspect stuff at the REPL and the jump back into vd at the sheet where I left off.


e.g.
from a sheet I do
<space>REPL<enter>
more usefully:


I'd like to fix the exception handling:

Ideally we'd catch the EOF and return quietly and for syntax errors i'd like to
continue
and stay in the REPL.Can anyone see the problem with that?
Well I hope this helps someone else too!
Note, I know about the
exec-python
command but you don't get command/expression history and it doesn't feel REPLy.Beta Was this translation helpful? Give feedback.
All reactions