I’m trying to run this ./elixiralgo_cli.ex --name=Jan
I have everything configured for the escript in elixir file and I have a module something like this
defmodule ElixirAlgo.CLI do
def main(args) do
args |> parse_args |> process
end
def process([]) do
IO.puts "No arguments given"
end
def process(options) do
IO.puts "Hello #{options[:name]}"
end
defp parse_args(args) do
{options, _, _} = OptionParser.parse(args,
switches: [name: :string]
)
options
end
end
When I’m trying to run this ./elixiralgo_cli.ex --name=Jan
I’m getting this error and I don’t know why
./elixiralgo_cli.ex: line 1: defmodule: command not found
./elixiralgo_cli.ex: line 2: syntax error near unexpected token `('
./elixiralgo_cli.ex: line 2: ` def main(args) do'
Can someone help?