Hey all,
I'm trying to learn nim by porting some python script of mine to nim. In one of it the core part is a call to fzf a fuzzy chooser like dmenu in the terminal. The python code looks something like the following:
fzf uses a clever "trick" to use still be interactive: It opens /dev/tty for interaction with the user. This way fzf works in pipes: find . -name "*.mp3" | fzf | xargs vlc.
So I tried to port that code to nim:
var p = startProcess(path_to_fzf)
var stream = p.inputStream()
stream.write(some_data)
stream.flush()
and this "works" with the only problem that the fzf TUI is not shown. But it does receive input, the output it produces when I input my specific input is correct.
I'm a bit stumped and don't really know how to debug that. Does python do something automatically which I have to do in nim manually?
$ nim --version
Nim Compiler Version 0.18.0 [Linux: amd64]
Copyright (c) 2006-2018 by Andreas Rumpf
active boot switches: -d:release -d:nativeStackTrace
$ fzf --version
0.17.4
Thanks in advance, syntonym
Check out my project ff that is a Windows wrapper for fzf written in Nim. It aims to improve the experience of using fzf on Windows and simplify various routine tasks.
I understand your challenge, it was a pain to figure this out. Hope this helps.
I also stumbled upon your code, but there you use options={poParentStreams} which I explicitly don't want. I prefilter the arguments I pipe into fzf and then do some additional computations on the chosen value. As far as I understand poParentStreams passes the nim stdin/stdout to fzf, such that fzf will then not read from stdin for its values but crawls the files itself.
I'm not linux if that makes any difference.
I see what you're saying and I had to make some changes due to this issue with fzf.
Just pushed an updated version, hope it works for your use case.