Ricardo Villagrana
Ricardo Villagrana

Reputation: 466

How to pass data from terminal in elixir

Hello I want to execute an elixir file and passing one string in my terminal and read it in the script. Something like this:

User>elixir script.exs create

I want the word "create" to be readed by elixir. Thank you.

Upvotes: 3

Views: 693

Answers (1)

Dogbert
Dogbert

Reputation: 222118

You can access the list of arguments using System.argv/0:

$ cat a.exs
IO.inspect System.argv
$ elixir a.exs foo bar
["foo", "bar"]

Upvotes: 5

Related Questions