How to ask and get input from user in elixir exs file

Hi friends, I have an elixir script file that I load it in my terminal like elixir github.exs or elixir github.exs "user_name", but I want to know can I ask a question from user and get my input-needed?

For example:

Please enter your GitHub username → after that my exs file wait for user and after he/she enter their username I can be able to ask some questions or use the input in my code

Something like shell can ask you no or yes or enter your password etc.

Thank you

For this, you can use the IO Module

IO.gets("Please enter your GitHub username?\n")
2 Likes

How can I get the user input, because I print System.argv() and it shows me an empty list

I think I found, I can put into a variable and can print anywhere I want

You would do it as @kevinschweikert wrote.

...
username = IO.gets("Please enter your GitHub username?\n")

#username will be what the user entered
some_func(username)
...
4 Likes