Fork me on GitHub
#planck
<
2019-10-29
>
austin.chamberlin15:10:05

I have another question today: Is there a way to invoke a command via planck.shell that prompts for keyboard input? I have a collection of strings and I'd like to send them to the cli tool fzf (https://github.com/junegunn/fzf) which displays them with a fuzzy-finder prompts, but my closest attempt so far does not display anything on the screen:

(def choices "one\ntwo\nthree\n")
(sh "fzf" :in choices)

mfikes15:10:11

The problem would be that the stdin and stdout of the sub-process are only visible to Planck

mfikes15:10:47

I think I understand your question: You want to send data to the stdin of that subprocess...

mfikes15:10:45

See the :in parameter to planck.shell/sh

mfikes15:10:06

In that, you could put a string that has newlines separating each input you want

austin.chamberlin16:10:24

that is what I did in the example above, and so far so good, but I'm hoping to see the fzf prompt on the screen from which I invoked planck, but it doesn't appear

mfikes16:10:16

Ahh, right. Planck has the stdout of that process, which you will only get back later when the process completes via the :out parameter returned from planck.shell/sh

austin.chamberlin16:10:51

okay, so I take it that means this is not possible today?

mfikes16:10:54

Yeah, with Planck, you can't really get at the input and output streams of the process in a dynamic way. I think Clojure's sh command lets you obtain a stream for out

austin.chamberlin16:10:46

okay, that's alright. I will make do.

austin.chamberlin16:10:49

do you see any technical reason a fzf-like tool could not be written in planck-compatible cljs?

mfikes16:10:08

I don't know what fzf is

mfikes16:10:58

You can certainly write a Planck program that prompts for input as it runs

austin.chamberlin16:10:53

this is a little bit more though, it renders in the terminal a dynamic list of options and as you type it narrows them down to the matches

austin.chamberlin16:10:02

i'll find a little animation

mfikes16:10:26

Oh, to do that, you would need to access individual keypresses I would bet

mfikes16:10:35

Planck doesn't currently have a get-keypress function or something along those lines

mfikes16:10:45

I suppose one could be added

austin.chamberlin16:10:59

alright well thanks for your help again Mike. I also want to say that I know there are other cljs-scripting projects out there but because planck can be so easily installed and the apis it ships with are so useful it makes it easier for me to get real things going with it. Thanks for that.

mfikes16:10:47

@austin.chamberlin Cool. And like I said, I think a blocking get-keypress (or some good name) might be useful for writing nifty little programs like that (even terminal based games, etc.)

mfikes16:10:23

Feel free to add an issue to Planck... it fundamentally doesn't seem too hard to implement something like that

mfikes20:10:56

@austin.chamberlin I might try to add a get-keypress capability later on tonight. I’m curious, are you interested in using such a thing, and if so, is the nature of your project such that you could make use of a pre-release with the functionality.