I am new to elixir and I decided to learn it by writing a small CLI app for personal use. I use the OptionParser module to parse the passed parameters, so I have this function:
def main(arguments) do
arguments
|> execute_function
end
defp execute_function(["run" | params]) do
IO.inspect params
{opts,a,b}= OptionParser.parse(
params,
aliases: [d: :db_name],
switches: [db_name: :string])
|> IO.inspect
end
if i call it from iex:
iex(1)> Potion.CLI.main(["run", "-d", "test", "--dev=qweb,xml"])
["-d", "test", "--dev=qweb,xml"]
{[db_name: "test", dev: "qweb,xml"], [], []}
{[db_name: "test", dev: "qweb,xml"], [], []}
everything is fine and works as expected. If i build it with escript though:
$ rm -rf potion && mix escript.build
Generated escript potion with MIX_ENV=dev
$ ./potion run -d test --dev=xml,qweb
["-d", "test", "--dev=xml,qweb"]
{[db_name: "test"], [], []}
So the question is: is it a bug or am I missing something?
P.S.
Elixir - 1.7.3
erlang-nox - 21.1.3