shahryarjb

shahryarjb

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

Marked As Solved

kevinschweikert

kevinschweikert

For this, you can use the IO Module

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

Also Liked

tomkonidas

tomkonidas

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)
...

Last Post!

tomkonidas

tomkonidas

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)
...

Where Next?

Popular in Questions Top

nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New

Other popular topics Top

grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 54006 488
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 40042 209
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New

We're in Beta

About us Mission Statement