Beginner Q regarding stdout #1081
-
Apologies for the simple Q, Not sure if this is a Calva related question or a more general one: When using the basilisp repo, I get fancy rich output to stdout using |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @dc-acronym, currently, the nREPL server only redirects the However, basilisp nrepl-server
nREPL server started on port 59975 on host 127.0.0.1 - nrepl://127.0.0.1:59975
{'a': 5} Are you primarily interested in displaying Basilisp core structures? If so, you can try the https://github.com/ikappaki/basilisp-pprint pretty printer library, which provides the same interface as the Clojure pretty printer. Alternatively, if you still want to use (import rich contextlib)
(with [_ (contextlib/redirect_stdout *out*)]
(rich/print {:a 5}) You might want to wrap this into a macro for convenience though. I hope this helps! |
Beta Was this translation helpful? Give feedback.
Hi @dc-acronym,
currently, the nREPL server only redirects the
*out*
stream to the client, meaning it captures output from core functions likepr
,print
, etc.However,
rich
writes directly tosys/stdout
, which is the terminal or window where the nREPL server was started. So, if you started the server withbasilisp nrepl-server
, the output would appear in that terminal:basilisp nrepl-server nREPL server started on port 59975 on host 127.0.0.1 - nrepl://127.0.0.1:59975 {'a': 5}
Are you primarily interested in displaying Basilisp core structures? If so, you can try the https://github.com/ikappaki/basilisp-pprint pretty printer library, which provides the same interface as the Clojure prett…