jasongilman / proto-repl

A Clojure Development Environment package for the Atom editor
https://atom.io/packages/proto-repl
MIT License
563 stars 50 forks source link

Can't read stdin #188

Closed meleyal closed 7 years ago

meleyal commented 7 years ago

I'm using Overtone, which asks you to authenticate with Freesound.org.

It prints this message in the repl:

Authorize in browser and paste code in Stdin.
https://www.freesound.org/apiv2/oauth2/authorize/?client_id=xyz&response_type=code

However when I paste the auth code I get the following error:

CompilerException java.lang.RuntimeException: Unable to resolve symbol: fajdsfjkalsdfjklsadfjk in this context, compiling:(/private/var/folders/00/n16mn_yd37dc1rfysy5fstwc0000gn/T/form-init2595763283589994510.clj:1:1)

I tried putting the auth code in double-quotes but then nothing happens.

Am I doing something wrong or does proto-repl not read stdin?

jasongilman commented 7 years ago

Doing some searching this seems like a common problem in editor tied REPLs. Do you have to paste it in every time or just the first time and then it caches it locally? If it's only the first time you can use lein repl to set it up and then use Proto REPL.

If it has to be done every time you use overtone then something like this might work: (with-in-str "my-secret-key\n" ..... overtone code)

You can see

(with-in-str 
 "foo\n"
 (read-line))

Returns "foo"

Or maybe there's another way to configure this for overtone through a config file.

meleyal commented 7 years ago

Overtone seems to require an access-token each time you fetch a new sample.

I tried with-in-str but that didn't work – am I using it correctly?

Authorize in browser and paste code in Stdin.
https://www.freesound.org/apiv2/oauth2/authorize/?client_id=xyz&response_type=code
(with-in-str 
 "my-secret-key\n"
 (read-line))

Also looked for a way to configure this but it seems it's just a local variable in freesound.clj.

Thanks for the lein repl tip, that works 👍, unfortunately yeah you have to do this each time.

jasongilman commented 7 years ago

In the code sample you pasted (read-line) should be replaced with the overtone code you're using. I'm assuming you're running something at the repl that triggers the Authorize in browser call.

Something that might be easier would be to use Lein repl and after you paste in the data connect to that repl session from Proto repl. When you start Lein repl it prints out a port and you can connect to a remote repl in Proto repl by specifying that port.