Cool CLIs in Elixir with IO.write/2

Cool CLIs in Elixir with IO.write/2

5 years ago
Anonymous $Dftgs0JzgE

https://medium.com/@dnsbty/cool-clis-in-elixir-with-io-write-2-577088a60ec4

Dennis BeattyBlockedUnblockFollowFollowingJan 9A couple months ago I wrote a script that needed to take a CSV file with ~500k lines and process records from each of those lines. I wanted some way to keep track of the progress, and logging out each line number on a separate line was filling my console really fast. Even just outputting a single period without a newline was overwhelming. This led to me researching how to overwrite a console line. I decided to make a quick video about how to do it and try to share my knowledge.

If you’ve been working with Elixir for very long, you’ve probably seen IO.inspect/2. You can add it to your pipelines to be able to easily debug output at various stages of processing. IO.inspect/2 is built on top of IO.puts/1 which you may also be familiar with. Basically IO.puts/1 prints whatever you tell it to in the console on a new line. This can be pretty useful for debugging output as well.

Cool CLIs in Elixir with IO.write/2

Jan 15, 2019, 10:34pm UTC
https://medium.com/@dnsbty/cool-clis-in-elixir-with-io-write-2-577088a60ec4 > Dennis BeattyBlockedUnblockFollowFollowingJan 9A couple months ago I wrote a script that needed to take a CSV file with ~500k lines and process records from each of those lines. I wanted some way to keep track of the progress, and logging out each line number on a separate line was filling my console really fast. Even just outputting a single period without a newline was overwhelming. This led to me researching how to overwrite a console line. I decided to make a quick video about how to do it and try to share my knowledge. > If you’ve been working with Elixir for very long, you’ve probably seen IO.inspect/2. You can add it to your pipelines to be able to easily debug output at various stages of processing. IO.inspect/2 is built on top of IO.puts/1 which you may also be familiar with. Basically IO.puts/1 prints whatever you tell it to in the console on a new line. This can be pretty useful for debugging output as well.